Let\'s say I have a Dog class.
Dog
Inside it I have a Map and one of the values is Breed.
Map
Breed
public
The great answer above can further be improved by method reference notation:
List dogs = ... Map> map = dogs.stream() .collect(Collectors.groupingBy(Dog::getBreed));