O'Reilly logo

Java 11 Cookbook by Mohamed Sanaulla, Nick Samoylov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting ready

There are two sets of collectors that use grouping—similar to the group by functionality of SQL statements—to present stream data as a Map object. The first set includes three overloaded groupingBy() factory methods:

  • Collector<T, ?, Map<K,List<T>>> groupingBy(Function<T,K> classifier): Creates a Collector object that collects the stream elements of the T type into a Map<K,List<T>> object using the provided classifier function to map the current element to the key in the resulting map.
  • Collector<T,?,Map<K,D>> groupingBy(Function<T,K> classifier, Collector<T,A,D> downstream): Creates a Collector object that collects the stream elements of the T type into a Map<K,D> object using the provided classifier function to map the current ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required