The asker of the original question, M Sach, said that instead of default methods, just put the default implementations in an abstract class.
Eran, the answerer, says that this would break existing code.
For example, suppose you have your own List
implementation written in Java 7, which does not inherit from AbstractList
. When you migrate your code to Java 8, what happens? There is suddenly a bunch of new methods in the List
interface that your own List
implementation does not have (the "default" implementation of those methods are in AbstractList
, which your class doesn't inherit)! Your code will no longer compile.
This means that when migrating to Java 8, you'd potentially have to write new methods for existing classes.
With default methods however, the default implementation is in the interface itself, so you don't have to write new methods.