What is a Predicate?

A Predicate is a function with single argument and return boolean true or false.predicate can be different datatype.
To create predicate it has Single method.

interface Predicate {
public boolean test(T t);
}

				
					import java.util.function.Predicate;

public class PredcateTest {
	public static void main(String[] args) {
		Predicate<Integer> pd = i -> i > 20;
		System.out.println("status one :- " + pd.test(15));
		System.out.println("status two :- " + pd.test(30));
	}
}
				
			

Output :-
status one :- false
status two :- true

1 thought on “What is a Predicate?”

Leave a Comment

Your email address will not be published. Required fields are marked *