public static void getOneTimeNum(int[] array) {
if (array == null || array.length < 1) {
return;
}
Map<Integer,Integer> map =new HashMap<Integer, Integer>();
for (int i = 0; i < array.length; i++) {
if (map.get(array[i]) == null) {
map.put(array[i], 1);
} else {
map.put(array[i], map.get(array[i]) + 1);
}
}
for (Integer key : map.keySet()) {
if (map.get(key) == 1) {//出现一次
System.out.print(key + " ");
}
}
}
本文参考:
http://blog.csdn.net/xidianluke/article/details/38267775