stream().collect

<p>For example, to compute the set of last names of people in each city:
* <pre>{@code
* Map<City, Set<String>> namesByCity
* = people.stream().collect(groupingBy(Person::getCity,
* mapping(Person::getLastName, toSet())));
* }</pre>



posted @ 2021-10-19 20:49  老运维  阅读(105)  评论(0)    收藏  举报