构造器出现多态的运行例子
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 谁调就是谁
不找借口失败,只找理由成功!