0 votes
in JAVA by (30.8k points)
What is a Predicate interface?

1 Answer

0 votes
by (30.8k points)
A Predicate is a functional interface that represents a function, which takes an Object and returns a boolean. It is used in several Stream methods like filter(), which uses Predicate to filter unwanted elements.

here is how a Predicate function looks like:

public boolean test(T object){

   return boolean;

}

You can see it just has one test() method which takes an object and returns a boolean. The method is used to test a condition if it passes; it returns true otherwise false.
...