Close

Java 8 Functional Interfaces - BiPredicate.or() Examples

Java 8 Functional Interfaces Java Java API 


Interface:

java.util.function.BiPredicate<T,U>

java.util.function.BiPredicateBiPredicateLogicBig

Method:

default BiPredicate<T,U> or(BiPredicate<? super T,? super U> other)

Returns a composed predicate that represents a short-circuiting logical OR of this predicate and another.


Examples


package com.logicbig.example.bipredicate;

import java.util.function.BiPredicate;

public class OrExample {

public static void main(String... args) {
BiPredicate<String, String> startsWith = String::startsWith;
BiPredicate<String, String> biPredicate = startsWith.or(String::endsWith);
boolean b = biPredicate.test("that is not enough", "enough");
System.out.println(b);
b = biPredicate.test("tall building", "tall");
System.out.println(b);
}
}

Output

true
true




See Also