IntPredicate and example

Description

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;
//w ww .j a  v a  2  s  . c o 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.