Movatterモバイル変換


[0]ホーム

URL:


Skip navigation links
Java™ Platform
Standard Ed. 8

Package java.util.function

Functional interfaces provide target types for lambda expressions and method references.

See: Description

Package java.util.function Description

Functional interfaces provide target types for lambda expressions and method references. Each functional interface has a single abstract method, called thefunctional method for that functional interface, to which the lambda expression's parameter and return types are matched or adapted. Functional interfaces can provide a target type in multiple contexts, such as assignment context, method invocation, or cast context:
     // Assignment context     Predicate<String> p = String::isEmpty;     // Method invocation context     stream.filter(e -> e.getSize() > 10)...     // Cast context     stream.map((ToIntFunction) e -> e.getSize())...

The interfaces in this package are general purpose functional interfaces used by the JDK, and are available to be used by user code as well. While they do not identify a complete set of function shapes to which lambda expressions might be adapted, they provide enough to cover common requirements. Other functional interfaces provided for specific purposes, such asFileFilter, are defined in the packages where they are used.

The interfaces in this package are annotated withFunctionalInterface. This annotation is not a requirement for the compiler to recognize an interface as a functional interface, but merely an aid to capture design intent and enlist the help of the compiler in identifying accidental violations of design intent.

Functional interfaces often represent abstract concepts like functions, actions, or predicates. In documenting functional interfaces, or referring to variables typed as functional interfaces, it is common to refer directly to those abstract concepts, for example using "this function" instead of "the function represented by this object". When an API method is said to accept or return a functional interface in this manner, such as "applies the provided function to...", this is understood to mean anon-null reference to an object implementing the appropriate functional interface, unless potential nullity is explicitly specified.

The functional interfaces in this package follow an extensible naming convention, as follows:

Since:
1.8
See Also:
FunctionalInterface
Skip navigation links
Java™ Platform
Standard Ed. 8


[8]ページ先頭

©2009-2025 Movatter.jp