Streams beginner

Predicate.not() for negation

Use Predicate.not() to negate method references cleanly instead of writing lambda wrappers.

✕ Java 8
List<String> nonEmpty = list.stream()
    .filter(s -> !s.isBlank())
    .collect(Collectors.toList());
✓ Java 11+
List<String> nonEmpty = list.stream()
    .filter(Predicate.not(String::isBlank))
    .toList();
👁

Cleaner negation

No need to wrap method references in lambdas just to negate them.

🔗

Composable

Works with any Predicate, enabling clean predicate chains.

📖

Reads naturally

Predicate.not(String::isBlank) reads like English.

Old Approach
Lambda negation
Modern Approach
Predicate.not()
Since JDK
11
Difficulty
beginner
Predicate.not() for negation
Available

Available since JDK 11 (September 2018).

Before Java 11, negating a method reference required wrapping it in a lambda. Predicate.not() lets you negate any predicate directly, keeping the code readable and consistent with method reference style throughout the stream pipeline.

Share 𝕏 🦋 in