Java Streams | groupingBy same elements
I have a stream of words and I would like to sort them according to the occurrence of same elements (=words). e.g.: {hello, world, hello} to Map<String, List<String>> hello, {hello, hello} world, {world} What i have so far: Map<Object, List<String>> list = streamofWords.collect(Collectors.groupingBy(???)); Problem 1: The stream seems to lose the information that he is processing Strings, therefore the compiler forces me to change the type to Object, List Problem 2: I don't know what to put inside the parentesis to group it by the same occurrence. I know that I am able to process single