构造器出现多态的运行例子

Son:

package com.sxt.parc;

public class Son extends Father {
    public void b() {
        System.out.println("A");
    }
    public static void main(String[] args) {
        Father f = new Son();
        f.a();
    }
}

Father:

package com.sxt.parc;

public class Father {
    public void a(){
        this.b();
        System.out.println("a");
    }
    public void b(){
        System.out.println("b");
    }
}
//运行结果:A
      a

 this 谁调就是谁

原文地址:https://www.cnblogs.com/qingfengzhuimeng/p/6829159.html