JAVA编译时多态 [TOC] JAVA编译时多态12345678910111213141516171819202122public class TestClass { public static void main(String[] args) { B b = new B(); }}class A{ public A(){ test(); } public void test(){ System.out.println("A的test方法"); }}class B extends A{ public B(){ test(); } public void test(){ System.out.println("B的test方法"); }} 12B的test方法B的test方法 12345678910111213141516171819public class TestClass { public static void main(String[] args) { B b = new B(); }}class A{ public A(){ test(); } public void test(){ System.out.println("A的test方法"); }}class B extends A{ public B(){ test(); }} 12A的test方法A的test方法