Single abstract method interfaces are well-known to Java developers. For example, the
Runnable interface contains one abstract method called
run. In Java 8, single abstract method interfaces are known as functional interfaces. The benefit of a functional interface is that a developer can specify an anonymous implementation wherever a reference to the interface is required (for example, passing an implementation of the
Runnable interface when instantiating a
Thread object). In this tutorial, we'll create a functional interface that contains one abstract method to generate a greeting.