In this article we will explore the Java 8 default method’s feature in interfaces. The Java 8 says “Default methods enable new functionality to be added to the interfaces in libraries and ensure binary compatibility with code written for older versions of those interfaces”.

As Java evolved over the years, the interfaces introduced in the Java library require adding new functionality. If you add new methods in the interface without having default methods feature, all the classes which already implemented the interfaces should undergo for a change. This results in changing thousands of lines of code. To avoid this, the Java 8 introduced default method feature. That is, if you want to add any functionality to the existing interface, you can add it by using default method feature without affecting the implementations.

Continue Reading...