Java Lambda - IntPredicate and example








IntPredicate and returns a composed predicate that represents a short-circuiting logical AND of this predicate and another.

Syntax

and has the following syntax.

default IntPredicate and(IntPredicate other)

Example

The following example shows how to use and.

import java.util.function.IntPredicate;
/*from w ww  .j a  v  a2s  .co  m*/
public class Main {

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

  }
}

The code above generates the following result.