I tried so hard but I couldn't be able to understand something. I don't get why it's possible to invoke a static method in this way. But it seems to be possible. Moreover I don't get the remaining prints. Can you help me? Thanks a lot.
interface I {
public void m(A a);
class IImpl {
public static void m(B b) {
System.out.println("m_IB");
}
}
}
class A extends I.IImpl implements I {
public void m(A a) {
System.out.println("m_AA");
}
}
class B extends A {
public void m(A a) {
super.m(a);
System.out.println("m_BA");
}
public static void m(B b) {
System.out.println("m_BB");
}
}
public class Ex3 {
public static void main(String[] args) {
A a = new A();
B b = new B();
a.m(b); //prints m_IB but how is it possible this invocation?
System.out.println();
I i = new A();
i.m(b); //why does it print m_AA ? I thought It should print m_IBB
System.out.println();
I j = new B();
j.m(b); //prints m_AA and m_BA but why isn't called the static method this time?
System.out.println();
}
}