Predicate or example

Description

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

Syntax

or has the following syntax.


default Predicate<T> or(Predicate<? super T> other)

Example

The following example shows how to use or.


import java.util.function.Predicate;
/*from  w w  w.j av  a2s  .co m*/
public class Main {

  public static void main(String[] args) {
    Predicate<String> i  = (s)-> s.length() > 5;
    Predicate<String> j  = (s)-> s.length() < 3;
    
    System.out.println(i.or(j).test("java2s.com "));
  }
}

The code above generates the following result.