Wil*_*m R 0 java arraylist hashmap
我一直在尝试从类似问题的顶部答案中修改代码,但我不能让它适用于arraylist长度
可以说我有
HashMap<Customer,ArrayList<Call>> outgoingCalls = new HashMap<Customer,ArrayList<Call>>();
程序运行时,它会存储在hashmap中进行的每个调用.我想运行这个hashmap并返回拨打过多电话的客户.我一直试图从上面的链接修改这个代码,但我完全迷失了
Entry<Customer,ArrayList<Call> mostCalls = null;
for(Entry<String,ArrayList<Call> e : outgoingCalls.entrySet()) {
if (mostCalls == null || e.getValue() > mostCalls.getValue()) {
mostCalls = e;
Run Code Online (Sandbox Code Playgroud)
关闭,但不完全.
Entry<Customer,ArrayList<Call>> mostCalls = null;
for(Entry<String,ArrayList<Call>> e : outgoingCalls.entrySet()) {
if (mostCalls == null || e.getValue().size() > mostCalls.getValue().size()) {
mostCalls = e;
}
}
Run Code Online (Sandbox Code Playgroud)