int[] arr = new int[]{3, 4, 5, 5, 5, 6, 2, 2}; IntStream.of(arr) .filter(data -> Collections.frequency(Arrays.asList(arr), data) > 1) .distinct() .forEach(data -> { System.out.println(data); } );