public class 练习2 {
/* . */
public static void main(String[] args) throws IOException, ParseException {
int [] arr={1,2,2,7,0,9,3,3,5,4,5,4};
TreeMap<Integer, Integer> t= new TreeMap<>();
for (int i = 0; i < arr.length; i++) {
t.put(arr[i], t.containsKey(arr[i])?t.get(arr[i])+1:1);
}
Set<Entry<Integer, Integer>> e = t.entrySet();
for (Entry<Integer, Integer> entry : e) {
if(entry.getValue()==1){
System.out.println(entry.getKey());
}
}
}
}
题目没有说按照数组排序的顺序打印出来,只是说把单个的打印!!! |