I have a small doubt about this reference in the following program,why the result is "I am in B",my question is how inside the super class constructor we are
able to access the subclass method.
class A {
A()
{this.print();}
public void print(){
System.out.println("I am in class A");
}
}
class B extends A {
public void print() {
System.out.println("I am in class B");
}
public static void main(String args[]) {
new Stest();
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…