Posts

Showing posts with the label default method

Functional Interface - Java8

Image
Before Java 8, an interface could only declare one or more methods also known as Abstract Method (method with no implementation, just the signature). Starting with Java 8 an interface can also have implementation of one or more methods (knows as Interface Default Method) and static methods along with abstract methods. Interface Default Methods are marked default keyword. So the question is, what is Functional Interface? An interface with Single Abstract Method (SAM) is called Functional Interface. Which means -  An interface with Single Abstract Method is a Functional Interface An interface with Single Abstract Method and zero or more default methods and zero or more static method is also a valid Functional Interface. Below is a functional interface with Single Abstract Method Below is a functional interface with Single Abstract Method along with default method and static method. You must have noticed the @FunctionalInterface annotation. What does it mea...