1
I guess the code below will do the trick in Java 8.
int[] array = { 2, 4, 6, 8, -3, 8, 2, 7, 2, 4 };
Arrays.stream(array).collect(Collectors.groupingBy(s -> s))
.forEach((k, v) -> System.out.println(k.toString() + ": " + v.size().toString()));
Prints:
2: 3
4: 2
8: 2
6: 1
7: 1
-3: 1