package test;
class FatherClass{
public int value;
public void f(){
value = 100;
System.out.println("FatherClass.value="+value);
}
}
class ChildClass extends FatherClass{
public int value;
public void f(){
super.f();
value = 200;
System.out.println("ChildClass.value="+value);
System.out.println(value);
System.out.println(super.value);
}
}
public class Test {
public static void main(String args[]){
ChildClass cc = new ChildClass();
cc.f();
}
}
输出结果:
FatherClass.value=100
ChildClass.value=200
200
100
[img]http://dl2.iteye.com/upload/attachment/0116/1296/8207d940-47f6-35c2-a06c-098092da51f4.jpg[/img]