Java Lambda - BiPredicate negate example








BiPredicate negate returns a predicate that represents the logical negation of this predicate.

Syntax

negate has the following syntax.

default BiPredicate<T,U> negate()

Example

The following example shows how to use negate.

import java.util.function.BiPredicate;
/* www.j av  a  2 s.c  om*/
public class Main {
  public static void main(String[] args) {
    BiPredicate<Integer, Integer> bi = (x, y) -> x > y;
    
    System.out.println(bi.test(2, 3));    
    System.out.println(bi.negate().test(2, 3));

  }
}

The code above generates the following result.