Close

Java 8 Functional Interfaces - BiPredicate.and() Examples

Java 8 Functional Interfaces Java Java API 


Interface:

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

java.util.function.BiPredicateBiPredicateLogicBig

Method:

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

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


Examples


package com.logicbig.example.bipredicate;

import java.util.function.BiPredicate;

public class AndExample {

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

Output

true
false




See Also