请教关于重写
class Base{
int i =99;
public void amethod(){
System.out.println("Base.amethod()");
}
}
public class RType extends Base{
int i =-1;
public static void main(String []args){
Base b = new RType ();
System.out.println(b.i);
b.amethod();
}
public void amethod(){
System.out.println("RType.amethod()");
}
}
最后结果是:
99
RType.amethod()");
对于Base b = new RType ();这一句b到底是属于谁的对象?为什么b.i=99 但是却调用了RType的方法?