父类
public class FatherClazz {
public void excuteor(){
doSomething();
}
public void doSomething(){
System.out.println("Father s do something!");
}
}
子类
public class SonClazz extends FatherClazz{
@Override
public void excuteor() {
super.excuteor();
}
@Override
public void doSomething() {
System.out.println("Son s do something");
}
}
测试
public static void main(String[] args) {
FatherClazz clazz = new SonClazz();
clazz.excuteor();
}
运行结果
说明:
很显然,父类中的excuteor方法调用了子类的dosomething方法