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(); } } public static void main(String[] args) { c x=new c(); x.showc(); } }
运行结果:
可以看到,要调用子类中与父类同名的方法,要加一个super.就可以了。