java list中统计相同值

Java code
    List<Object> list = new ArrayList<Object>(); 
Map <Object,Integer> map = new HashMap <Object,Integer>(); for(Object o :list)
{
     map.put(o, map.get(o)==null?1:map.get(o)+1); 
}
 

 

你可能感兴趣的:(java)