Default Methods in interfaces
Let's learn what default methods in interfaces are and why they were introduced in Java 8.
What are default methods?
Before Java 8, we could only declare abstract methods in an interface. However, Java 8 introduced the concept of default methods. Default methods are methods that can have a body. The most important use of default methods in interfaces is to provide additional functionality to a given type without breaking down the implementing classes.
Before Java 8, if a new method was introduced in an interface then all the implementing classes used to break. We ...