在java中,子类中调用与父类同名的方法(即父类中被覆盖的方法)用super来调用即可,下面是示例:
子类父类的定义
public class b { void show() { System.out.println("b"); } } public class c extends b { void show() { System.out.println("c"); } void showc() { super.show(); show(); } }
在main执行
package lei; public class a { public static void main(String[] args) { c x=new c(); x.showc(); } }
执行结果