当找到或存在值时,我试图在哈希表中打印键值。此代码似乎不起作用。
Map<String,Integer> map = new HashMap<String, Integer>();
for(int j=0;j<al.size();j++){
Integer count = map.get(al.get(j));
map.put(al.get(j), count==null?1:count+1); //auto boxing and count
}
int max = Collections.max(map.values());
if( map.containsValue(max))
{
System.out.println(map.keySet());
}