Functional interfaces revisited
We used several functional interfaces in the previous examples. In this section, we will examine in more detail how they are created and illustrate a number of predefined functional interfaces available for immediate use in Java 8.
As mentioned earlier, a functional interface is an interface that has one and only one abstract method. It may have zero or more default methods. Since the interface has only one abstract method, the system is able to know which method to match to a lambda expression. This abstract method is called the functional method.
Creating a functional interface
The IntegerConcatenation
interface is duplicated here as an example. Note the use of the @FunctionalInterface
annotation. While not required, ...
Get Learning Java Functional Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.