Java Lambda - LongPredicate negate example








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

Syntax

negate has the following syntax.

default LongPredicate negate()

Example

The following example shows how to use negate.

import java.util.function.LongPredicate;
/*w  w w  .  j a  v  a  2 s  .  c  o m*/
public class Main {

  public static void main(String[] args) {
    LongPredicate i = (l) -> l > 0;
    
    System.out.println(i.negate().test(Long.MAX_VALUE));
  }
}

The code above generates the following result.