0 votes
in JAVA by
What is a Predicate interface?

1 Answer

0 votes
by
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.

Related questions

0 votes
asked May 22, 2022 in JAVA by AdilsonLima
0 votes
0 votes
asked Feb 27, 2023 in JAVA by Robindeniel
...