filter is an intermediate operation that will be performed only if the Stream pipeline ends in a terminal operation.
For instance:
Stream.of("d2", "a2", "b1", "b3", "c") .filter(s -> { s.startsWith("b"); System.out.println("filter: " + s); return true; }) .forEach (System.out::println);
Be that as it may, your filter method is useless, as it always returns true and therefore does not perform filtering.
source share