群组、分区、下游收集器
群组和分区(P23-25)
Map<String, List<Locale>> countryToLocales = locales.collect(Collectors.goupingBy(Locale::getCountry));
//函数Locale::getCountry是群组的分类函数。
//Yields locales [it_CH, de_CH, fr_CH]
List<Locale> swissLocales = countryToLocales.get("CH");Map<Bolean,List<Locale>> englishAndOtherLocales = locales.collect(
Collectors.partitioningBy(l -> l.getLanguage().equals("en")));
List<Locale> englishLocales = engLishAndOtherLocales.get(true);下游收集器(P24-28)
Last updated