Giving this code :
List<String> list1 = Arrays.asList("Collect","Collection","by","Collectors");
Map<String, Long> map = list1.stream().collect(Collectors.groupingBy(list1::toString, Collectors.counting()));
System.out.println(map);
It shows me :
error: no suitable method found for groupingBy(list::toString,Collector< Object,CAP#1,Long>)
I know that if list1 was a custom class that have let's say getName method and replace list1::toString by list1::getName it would work, but why not toString()?