public static void main(String[] args) {
int[] arr = { 3, 1, 2, 6, 8, 2, 1, 4, 5, 0, 8, 5, 133, 12, 314, 344, 314, 9, 1, 4, 6 };
HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
for(int i :arr){
map.put(i, 0);
}
for (int i : arr) {
map.put(i, (map.get(i)+1));
}
Set<Integer> keySet = map.keySet();
for(int i : keySet){
if(map.get(i)==1){
System.out.println(i);
}
}
} |