Mastering Java Functional Interfaces with Examples

Get your hands dirty on functional interfaces

Larry | Peng Yang
Mastering Java

--

Photo by Kelly Sikkema on Unsplash

Overview

As we have learned in my Java Lambda Expression post, a functional interface in Java is an interface that only has one abstract method and it is can be implemented by a Java lambda expression. An abstract method is meant only one method which is not implemented. An interface can have multiple methods, e.g. default methods and static methods, both with implementations, but as long as the interface only has one method that is not implemented, the interface is considered a functional interface.

In this post, we will be focusing on another handy Java package — java.util.function, which provides a set of reusable common functional interfaces (and their corresponding lambda) definitions that the programmers can use in their code instead of creating brand new functional interfaces.

This post covers the following:

  1. Implementing and using functional interfaces
  2. Commonly used functional interfaces in java.util.function package
  3. Writing our own functional interface

Implementing and using functional interfaces

--

--