© Ralph Lecessi 2019
Ralph LecessiFunctional Interfaces in Javahttps://doi.org/10.1007/978-1-4842-4278-0_4

4. Functions

Ralph Lecessi1 
Kendall Park, NJ, USA

Section 4.1: The Function Interface

Function is a functional interface with two type parameters T and R. Its functional method, called apply, takes an argument of type T and returns an object of type R. Functions are ideal for converting an object of type T to one of type R.
public interface Function<T, R>
    R apply(T t);
A Function of String, Integer type is declared as follows:
    Function<String, Integer> f;
Function f’s apply method will accept a String argument and return an Integer. The following statement represents this function using a lambda expression: ...

Get Functional Interfaces in Java: Fundamentals and Examples now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.