I want to count the different elements of a stream and am wondering why
Stream stream = Stream.of(\"a\", \"b\", \"a\", \"c\", \"c\", \"a\", \"a
The following should work if you are not using parallel streams:
final int[] counter = {0}; stream.peek(s -> counter[0]++);