Java: Predicate

Published: 15 March 2024
on channel: HowTo:
21
5

This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

A Functional Interface is an Interface which allows only one Abstract method within the Interface scope. There are some predefined functional interface in Java like Predicate, consumer, supplier etc. The return type of a Lambda function (introduced in JDK 1.8) is a also functional interface.

The Functional Interface PREDICATE is defined in the java.util.function package. It improves manageability of code, helps in unit-testing them separately, and contain some methods like:
isEqual(Object targetRef) : Returns a predicate that tests if two arguments are equal according to Objects.equals(Object, Object).
and(Predicate other) : Returns a composed predicate that represents a short-circuiting logical AND of this predicate and another.
negate() : Returns a predicate that represents the logical negation of this predicate.
or(Predicate other) : Returns a composed predicate that represents a short-circuiting logical OR of this predicate and another.
test(T t) : Evaluates this predicate on the given argument.boolean test(T t)

00:00 - Intro
00:05 - Simple Predicate
00:22 - Predicate in Collection
01:13 - Predicate AND


On this page of the site you can watch the video online Java: Predicate with a duration of hours minute second in good quality, which was uploaded by the user HowTo: 15 March 2024, share the link with friends and acquaintances, this video has already been watched 21 times on youtube and it was liked by 5 viewers. Enjoy your viewing!