I have 2 interfaces
public interface A {
method1();
method2();
}
public interface B extends A {
method3();
method4();
:
}
I am in need of converting (upcasting) B to A in one of class. But so far I could not figure out how do I do that.
Assume "methodWhichReturnB" is method which returns B.
public class C {
public void method10() {
A a = methodWhichReturnB; // din't work
A aa = (A) methodWhichReturnB // din't work
}
}
I am getting compilation error "Inconvertible types; cannot cast B to A".
Is there way I can upcast B to A ?