1 class Test1_Extends{ 2 public static void main(String[] args) { 3 Son s = new Son(); 4 s.method(); 5 6 7 } 8 } 9 10 class Fu{ 11 public void method(){ 12 System.out.println("3"); 13 } 14 } 15 16 class Son extends Fu{ 17 public Son(){ 18 19 } 20 21 public void print(){ 22 System.out.println("1"); 23 } 24 25 public void method(){ 26 super.method(); 27 System.out.println("2"); //方法的重写 28 } 29 }
子类可以通过super.来调用父类的方法
原文:http://www.cnblogs.com/panw3i/p/6354016.html