Before Java 8 your interfaces could contain method declarations, but no implementation code. One of the new features of Java 8 is the option to provide default implementations for methods right in your interface code itself.

 

Backward Compatibility

The main reason for adding this functionality was to allow the Java 8 team to add new methods to the Collections API (e.g. the forEach() method).  Without this, existing third-party libraries that already implement the Java collections API would not have worked with Java 8.  These vendors would have been forced to upgrade their code for Java 8.  Even worse, they would have to create and maintain separate versions if they wanted to continue supporting their non-Java 8 users.

Instead of breaking backward compatibility, the Java 8 team came up with a clever solution.  Allow developers to include a default implementation for their methods right in the interface itself — very similar to abstract classes.

 

Continue reading: How to Use Java 8′s Default Methods