首页 > 代码库 > this and super

this and super

技术分享
class FatherClass {
    public int value;
    public void f() {
        value = 100;
        System.out.println("FatherClass,value = "http://www.mamicode.com/+ value);
    }
}

class ChildClass extends FatherClass {
    public int value;
    public void f() {
        super.f();
        value = 200;
        System.out.println("ChildClass,value = "http://www.mamicode.com/+ value);
        System.out.println(value);
        System.out.println(super.value);
    }
}

public class Demo {
    public static void main(String[] args) {
        ChildClass cc = new ChildClass();
        cc.f();
    }
}
View Code

画图分析:

技术分享

 技术分享

 

this and super