Java 8 – What is functional Interface?


Functional interface is a new addition to Java 8. In simple terms, an interface which has one single abstract method is qualified as Functional interface. The built-in classes in JDK are full of examples of Functional Interfaces(Runnable, Callable, ActionListener). Java 8 formalized such interface definition with @FunctionalInterface annotation. FunctionalInterface is also useful while creating lambda expressions. Those who are not familiar with Lambda expression, it was again a new feature introduced in Java 8. Lambda helps developers to write concise code. Its expressive syntax saves developer’s time. Before Lambda, for every single method declaration of an interface, developers had to create Class. Eventually, an application source code is filled with many small classes which just provide an implementation for one single method. FunctionalInterface and Lambda expressions are considered to be best practice for writing neat code. Lets have a look at how JavaDoc describes FunctionalInterface
Continue reading