Java 8 Default Methods in Interface

Java Interface always can contain the method declaration and cannot contain method implementation (method body), “there is no possible way of adding method implementation to a Java Interface” has become a myth now after the introduction of Default Method in Java 8. Default Method or Defender methods is a new feature which lets the developer add a new method to an existing interface and provides the implementation for it without breaking existing implementation of the interface. For defining method body, we simply need to add Java default keyword while declaring the method. Let’s look into the below example and understand how Default Methods works. [Read more…]