标签:
class Base{
????int x = 1;
????static int y = 2;
}
class Subclass extends Base{
????int x = 4;
????int y = 5;
}
public class Test02{
????public static void main(String[] args){
????????Subclass s = new Subclass();
????????System.out.println(s.x+" "+s.y);
????????Base s1 = new Subclass();
????????System.out.println(s1.x+" "+s1.y);
????}
}
?
/*
* 实验结果:4 5
????????????1 2
?
* 实验结论:编译时根据调用该方法的类或对象所属的类决定
*/
标签:
原文地址:http://www.cnblogs.com/iucforever/p/4828607.html