标签:inf out child end super extend ima The img
super 关键字
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 Child {
public static void main(String[] args) {
ChildClass childClass = new ChildClass();
childClass.f();
}
}
FatherClass.value=100
ChildClass.value=200
200
100
标签:inf out child end super extend ima The img
原文地址:https://www.cnblogs.com/hglibin/p/11372470.html