Java 8 interface default methods vs. non-abstract methods in abstract classes - are there any differences between the two (besides the differences of iface - class, visibili
Firstly Default methods allow you to add new methods to interface without breaking existing implementations.
Also take an example of Collections
class which is a utility class for Collection
interface right.
So using default methods we can now move all the utility methods as default implementation in the Collection
itself, which will make more sense than making a separate class for such utilities.
Also you will be able to inherit methods from multiple interfaces, which could not have been done using plain abstract
classes.