Java Lambda - IntPredicate example








IntPredicate represents a predicate, which is a boolean-valued function, of one int-valued argument. This is the int-consuming primitive type specialization of Predicate.

Method

  1. IntPredicate test
  2. IntPredicate and
  3. IntPredicate negate
  4. IntPredicate or




Example

The following example shows how to use IntPredicate.

import java.util.function.IntPredicate;
/*from  w ww. j  av a 2s  .  c  o m*/
public class Main {

  public static void main(String[] args) {
    IntPredicate i = (x)-> x < 0;
    
    System.out.println(i.test(123));

  }
}

The code above generates the following result.