Java Lambda - DoublePredicate or example

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


or has the following syntax.

default DoublePredicate or(DoublePredicate other)


The following example shows how to use or.

import java.util.function.DoublePredicate;
/*  w  w w .  ja  v  a 2 s  .c o m*/
public class Main {

  public static void main(String[] args) {
    DoublePredicate dp = (d) -> d > 0;

    DoublePredicate dp1 = (d) -> d == 0;


The code above generates the following result.