public static void main(String[] args) {
Father f = new Son();
Son s = new Son();
System.out.println(f.x);
System.out.println(s.x);
}
}
class Father
{
int x = 1;
}
class Son extends Father
{
int x = 2;
}
这两个输出一个是1,另一个是2,这是为什么呢?
对象f对象头部指向的Father类还是其他什么原因呢?困扰多时了,求大神解答!!!