Function Interface

This lesson explains the Function interface in Java.

Function is a category of functional interfaces that takes an object of type T and returns an object of type R.

Until now, the functional interfaces that we’ve discussed have either not taken any argument(Supplier), not returned any value(Consumer), or returned only a boolean(Predicate).

Function interfaces are very useful as we can specify the type of input and output.

Below are some of the interfaces that fall in this category.

Let us discuss some types of Function functional interfaces.

Function<T, R>

The function takes only one argument of type T and returns a result of type R.

The following is the list of all the methods in the Function<T, R> interface.

Get hands-on with 1400+ tech skills courses.