Skip to content

Instantly share code, notes, and snippets.

@hertzsprung
Created June 21, 2012 20:03
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 hertzsprung/2968209 to your computer and use it in GitHub Desktop.
Save hertzsprung/2968209 to your computer and use it in GitHub Desktop.
Filtering a collection with a predicate
List<String> names = Arrays.asList("Alice", "Bob", "Charlie", "Dave");
List<String> filteredNames = names
.filter(e -> e.length() >= 4)
.into(new ArrayList<String>());
for (String name : filteredNames) {
System.out.println(name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment