Predicate negate example
Description
Predicate negate returns a predicate that represents the logical negation of this predicate.
Syntax
negate
has the following syntax.
default Predicate<T> negate()
Example
The following example shows how to use negate
.
import java.util.function.Predicate;
/* ww w. j a va 2 s . co m*/
public class Main {
public static void main(String[] args) {
Predicate<String> i = (s)-> s.length() > 5;
System.out.println(i.negate().test("java2s.com "));
}
}
The code above generates the following result.
Home »
Java Lambda »
java.util.function Reference »
Java Lambda »
java.util.function Reference »