Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/streams/predicate-not.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ oldCode: |-
modernCode: |-
List<String> nonEmpty = list.stream()
.filter(Predicate.not(String::isBlank))
.toList();
.collect(Collectors.toList());
summary: "Use Predicate.not() to negate method references cleanly instead of writing\
\ lambda wrappers."
explanation: "Before Java 11, negating a method reference required wrapping it in\
Expand Down
3 changes: 2 additions & 1 deletion proof/streams/PredicateNot.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
//JAVA 25+
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

/// Proof: predicate-not
/// Source: content/streams/predicate-not.yaml
void main() {
List<String> list = List.of("hello", "", "world", " ");
List<String> nonEmpty = list.stream()
.filter(Predicate.not(String::isBlank))
.toList();
.collect(Collectors.toList());
}