interface A {
public void doSomething();
}
interface B extends A {
public void doSomethingElse();
}
public class AClass implements A, B {
public void doSomething() {}
public void doSomethingElse() {}
}
Why does Java permit such a declaration? What’s the use of implementing both interfaces when same thing can be achieved by implementing the SubInterface (B)?
I think the “why” question can only be answered by Java designers.
One reason might be that it permits retrofitting
extends AtoBwithout breaking any existing classes that already happen to implement both.Another reason for using this construct might be to make it immediately clear to the end user of
AClassthat the class implements bothAandB. This is discussed in Redundant implementation of List interface in ArrayList.java