- public class shuzuzhongcongfude {
public static void main(String[] args) {
int[] array={2,3,1,0,2,5,3};
Map<Integer,Integer> map=new HashMap<Integer,Integer>();
for(int i=0;i<array.length;i++){
if(!map.containsKey(array[i])){
map.put(array[i],1);
}else{
int value=map.get(array[i]);
map.put(array[i],value+1);
}
}
for(Map.Entry<Integer, Integer> m:map.entrySet()){
if(m.getValue()>1)
System.out.println(m.getKey()+":"+m.getValue());
}
}
}
数组中重复的数
最新推荐文章于 2022-04-08 11:16:51 发布