Java Lambda - LongPredicate or example

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


or has the following syntax.

default LongPredicate or(LongPredicate other)


The following example shows how to use or.

import java.util.function.LongPredicate;
// w  w  w  .  j a v  a2s . co  m
public class Main {

  public static void main(String[] args) {
    LongPredicate i = (l) -> l > 0;
    LongPredicate j = (l) -> l == 0;

The code above generates the following result.