package otherTest; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.Map; public class Calculation { public static void main(String[] args) { //找出数组中重复最多的数 int[] arrInt = {1,2,3,4,5,5,4,3,2,1,1,2}; Map<Integer,Integer> map = new HashMap<Integer,Integer>(); for(int i=0;i<arrInt.length;i++){ if(map.containsKey(arrInt[i])){ int count = map.get(arrInt[i]); map.put(arrInt[i], count+1); }else{ map.put(arrInt[i], 1); } } Collection<Integer> c = map.values(); Object[] o = c.toArray(); Arrays.sort(o); for(Map.Entry<Integer,Integer> m:map.entrySet()){ if(m.getValue()==o[o.length-1]){ System.out.println(m.getKey()+":"+m.getValue()); } } } }