September 2019
Intermediate to advanced
816 pages
18h 47m
English
Earlier, we mentioned that two of three flavors of groupingBy() take another collector as an argument. Moreover, we said that this can be any collector. By any collector, we mean groupingBy() as well.
By passing groupingBy() to groupingBy(), we can achieve n-levels of grouping or multilevel grouping. Mainly, we have n-levels of classification functions.
Let's consider the following list of Melon:
List<Melon> melonsSugar = Arrays.asList( new Melon("Crenshaw", 1200, HIGH), new Melon("Gac", 3000, LOW), new Melon("Hemi", 2600, HIGH), new Melon("Hemi", 1600), new Melon("Gac", 1200, LOW), new Melon("Cantaloupe", 2600, MEDIUM), new Melon("Cantaloupe", 3600, MEDIUM), new Melon("Apollo", 2600, MEDIUM), new Melon("Horned", 1200, ...