Function interface¶
Function<T,R> is a Functional Interface within the Java framework, specifically categorized as a unary function from T to R^[600-developer__java__java8__java8-lambda.md]. It is designed to represent a method that accepts a single argument and produces a result.^[600-developer__java__java8__java8-lambda.md]
Type Parameters¶
The interface is defined by two generic type parameters:
T: the type of the input (parameter) provided to the function.^[600-developer__java__java8__java8-lambda.md]R: the type of the result (return value) produced by the function.^[600-developer__java__java8-lambda.md]
Usage¶
To invoke the function encapsulated by a Function object, the apply method is used^[600-developer__java__java8__java8-lambda.md]. This allows the logic defined within the interface implementation to be executed with the provided argument^[600-developer__java__java8__java8-lambda.md].
Related Concepts¶
- [[Consumer]]: A unary function from
Ttovoid. - [[Predicate]]: A unary function from
Ttoboolean. - [[Supplier]]: A function with no arguments that returns
R. - [[Lambda]]
Sources¶
^[600-developer__java__java8__java8-lambda.md]