Skip to content

Instantly share code, notes, and snippets.

@Jayasagar
Created December 17, 2017 15:10
Show Gist options
  • Save Jayasagar/4c35d397ff1b983194073bf179a8e4ee to your computer and use it in GitHub Desktop.
Save Jayasagar/4c35d397ff1b983194073bf179a8e4ee to your computer and use it in GitHub Desktop.
List<Consumer> consumersByAge =
consumerList
.stream()
// filter is an intermediate operation
.filter(consumer -> consumer.getAge() > 30)
// collect is a terminal operation
.collect(Collectors.toList());
System.out.println(consumersByAge);
// Output: [Consumer(name=Sri, city=Hyd), Consumer(name=Bob, city=Berlin)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment