Java Lambda - IntPredicate or example








Returns a composed predicate that represents a short-circuiting logical OR of this predicate and another. When evaluating the composed predicate, if this predicate is true, then the other predicate is not evaluated. Any exceptions thrown during evaluation of either predicate are relayed to the caller; if evaluation of this predicate throws an exception, the other predicate will not be evaluated.

Syntax

or has the following syntax.

default IntPredicate or(IntPredicate other)




Example

The following example shows how to use or.

import java.util.function.IntPredicate;
/*w w w .  j a  v  a  2  s  .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.or(j).test(123));

  }
}

The code above generates the following result.