I'm looking for functional, java 8, solution for a problem of splitting an array into list of sublists containing equal elements;
i.e.:
ArrayList.asList(1,2,2,3,4,4,4) --> List([1],[2,2],[3], [4,4,4])
so far I managed to come only to the solution for counting these elements:
Map<Integer,Integer> count = lst.stream().collect(Collectors.groupingBy(s -> s, Collectors.counting()));
results in a map of count - value, which is not good enough.
would be glad to receive some hints, I guess I do need to map first somehow and then get the entrySet;