Predicate
- Functional Interface which represents a boolean-values function that takes one argument.
- Provides a convenient way to define and pass around functions that return a true or false value based on their input.
Definition
@FunctionalInterface
public interface Predicate<T> {
boolean test(T t);
}
It is also Generic.
Usage
Predicate<String> isEvenLength = s -> s.length() % 2 == 0;
boolean result = isEvenLength.test("Hello");
Backlinks