Filtering a collection with Java 8 Streams involves calling stream() on the collection, applying filter() with a Predicate describing the condition to keep, and then collecting the matching elements back into a new collection.
Given a List<Order>, orders.stream().filter(o -> o.getTotal() > 100).collect(Collectors.toList()) extracts only the orders whose total exceeds 100 into a brand-new list.
List<String> words = Arrays.asList("cat", "elephant", "dog", "giraffe");
List<String> longWords = words.stream()
.filter(w -> w.length() > 3)
.collect(Collectors.toList());
System.out.println(longWords); // [elephant, giraffe]A concise interview answer is
I call stream() on the collection, apply filter() with a Predicate describing what to keep, and collect the results into a new collection with collect(Collectors.toList()) or similar. It's a non-destructive way to derive a subset — the original collection is never modified — and if I just need to remove matching elements in place, removeIf() is the more direct choice.
Last updated: 16 July 2026
Previous question: What is the difference between map() and flatMap() in Java streams?
Next question: What are default methods in Java 8, and why were they introduced?