LongPredicate or example

Description

LongPredicate or returns a composed predicate that represents a short-circuiting logical OR of this predicate and another.

Syntax

or has the following syntax.


default LongPredicate or(LongPredicate other)

Example

The following example shows how to use or.


import java.util.function.LongPredicate;
/*w w  w.  ja va2s. co m*/
public class Main {

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

The code above generates the following result.