Overview of default methods conflicts.
-
super class with interface conflict
- base class
class CustomClass extends SuperClass implements Interface1 {}
- super class
class SuperClass { public String get() { return "SuperClass"; } }
- interface
interface Interface1 { default String get() { return "Interface1"; } }
then if you call method
get()
on an instance ofCustomClass
it will be called method fromSuperClass
:assertThat(new CustomClass().get(), is("SuperClass"));
Note that If we narrow scope of
get()
method in superclassclass SuperClass { String get() { return "SuperClass"; } }
we obtain compile time error under
class CustomClass extends SuperClass implements Interface1 {}
- base class
-
interface with other interface conflict - compile time error