Close

Java 8 Functional Interfaces - BiPredicate.negate() Examples

Java 8 Functional Interfaces Java Java API 


Interface:

java.util.function.BiPredicate<T,U>

java.util.function.BiPredicateBiPredicateLogicBig

Method:

default BiPredicate<T,U> negate()

Returns a predicate that represents the logical negation of this predicate.


Examples


package com.logicbig.example.bipredicate;

import java.util.function.BiPredicate;

public class NegateExample {

public static void main(String... args) {
BiPredicate<String, String> startsWith = String::startsWith;
BiPredicate<String, String> biPredicate = startsWith.negate();
boolean b = biPredicate.test("enough is enough", "enough");
System.out.println(b);
b = biPredicate.test("she is tall", "tall");
System.out.println(b);
}
}

Output

false
true




See Also