Skip to content

Instantly share code, notes, and snippets.

@codeaholicguy
Last active December 19, 2015 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeaholicguy/f325783aa98fbbcaeacb to your computer and use it in GitHub Desktop.
Save codeaholicguy/f325783aa98fbbcaeacb to your computer and use it in GitHub Desktop.
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