Functional Interfaces

Java 8 introduced the concept of functional interfaces, interfaces that contains exactly one abstract method. These interfaces are used extensively in lambda expressions, streams and in method references.

To make any interface as Functional Interface then we have to use the following annotation just above the interface @FunctionalInterface. The @FunctionalInterface annotation is used to indicate that an interface is intended to be a functional interface. This annotation is optional but provides compiler-level checks.

Code Example
Output
my-method executed

Output

Addition: 8
Subtraction: 2