BiPredicate or example
Description
BiPredicate or returns a composed predicate that represents a short-circuiting logical OR of this predicate and another.
Syntax
or
has the following syntax.
default BiPredicate<T,U> or(BiPredicate<? super T,? super U> other)
Example
The following example shows how to use or
.
import java.util.function.BiPredicate;
/* w w w . j a v a2 s .c o m*/
public class Main {
public static void main(String[] args) {
BiPredicate<Integer, Integer> bi = (x, y) -> x > y;
BiPredicate<Integer, Integer> eq = (x, y) -> x -2 > y;
System.out.println(bi.test(2, 3));
System.out.println(bi.or(eq).test(2, 3));
System.out.println(bi.or(eq).test(8, 3));
}
}
The code above generates the following result.
Home »
Java Lambda »
java.util.function Reference »
Java Lambda »
java.util.function Reference »