Predicate Functional Interface
This lesson introduces the Predicate functional interface. We will discuss where a Predicate interface can be used and how to use it.
We'll cover the following...
We'll cover the following...
Introduction to the Predicate interface
Java 8 provides some in-built functional interfaces in the java.util.function package. These interfaces are required so that, while writing lambda expressions, we don’t need to worry about creating a functional interface.
There are 43 predefined interfaces in Java 8. Remembering all of them is a bit difficult, so we will divide them into categories and look at each category. The first category that we are looking at in this lesson is Predicate.
Below are the interfaces in this category:
| Interface Name | Description | Abstract Method |
|---|---|---|
Predicate<T> |
Represents a predicate (boolean-value function) of one argument (reference type) | boolean test(T t) |
DoublePredicate |
Accepts one double-value argument | boolean test(double value) |
IntPredicate |
Accepts one int-value argument. |