Java: Predicate

Pubblicato il: 15 marzo 2024
sul canale di: HowTo:
20
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


In questa pagina del sito puoi guardare il video online Java: Predicate della durata di ore minuti seconda in buona qualità , che l'utente ha caricato HowTo: 15 marzo 2024, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 20 volte e gli è piaciuto 5 spettatori. Buona visione!