Java tutorial
import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; public class Main { public static void main(String[] args) { Integer[] arr = { 1, 2, 3, 1, 4, 4, 1, 5 }; System.out.println(Arrays.toString(arr)); List<Integer> l = Arrays.asList(arr); System.out.println(l); Set<Integer> set = new HashSet<Integer>(); for (int j = 0; j < l.size(); j++) { if (Collections.frequency(l, l.get(j)) > 1) { set.add(l.get(j)); } } System.out.println("dups are:" + set); } }