The Java Version Almanac
javaalmanac.io
Feedback on this page?

Not Predicate

With the static method Predicate.not() we can invert conditions. This is particular useful in combination with method references.

Since Java 11

import static java.util.function.Predicate.not; import java.util.List; public class NotPredicate { public static void main(String... args) { List.of("", "venus", " ", "mars", " ", "earth") // .stream() // .filter(not(String::isBlank)) // .forEach(System.out::println); } }

This snippet at GitHub