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

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 谁调就是谁

posted @ 2017-05-09 09:48  清风追梦enjoy  阅读(143)  评论(0编辑  收藏  举报