This topic is about Java 11 – Not Predicate.
Java 11 introduced new method to Predicate interface as not() to negate an existing predicate similar to negate method.
Consider the following example −
ApiTester.java
import java.util.Arrays; import java.util.List; import java.util.function.Predicate; import java.util.stream.Collectors; public class APITester { public static void main(String[] args) { List<String> tutorialsList = Arrays.asList("Java", "\n", "HTML", " "); List<String> tutorials = tutorialsList.stream() .filter(Predicate.not(String::isBlank)) .collect(Collectors.toList()); tutorials.forEach(tutorial -> System.out.println(tutorial)); } }
Output
Java HTML
In this topic we learned about Java 11 – Not Predicate. To know more, Click Here.
Pingback: Java 11 - Optional Class - Adglob Infosystem Pvt Ltd