Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
List<Person> people = new ArrayList<>();
String result = people.stream()
.filter(p -> p.getAge() > 20)
.map(Person::getLastname)
.collect(Collectors.joining(","));
List<String> list = people.stream()
.filter(p -> p.getAge() > 20)
.map(Person::getLastname)
.collect(Collectors.toList());
Map<Integer, List<Person>> map = people.stream()
.filter(p -> p.getAge() > 20)
.collect(Collectors.groupingBy(Person::getAge));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.