I have to find the element with highest occurrences in a double array. I did it like this:
int max = 0; for (int i = 0; i < array.length; i++) { in
The solution with Java 8
int result = Arrays.stream(array) .boxed() .collect(Collectors.groupingBy(i->i,Collectors.counting())) .values() .stream() .max(Comparator.comparingLong(i->i)) .orElseThrow(RuntimeException::new));