public class Person { public void fight(){ System.out.println("Person战斗"); say(); } public void say(){ System.out.println("Person说话"); } }
public class Student extends Person { @Override public void fight() { System.out.println("Student战斗!"); super.fight(); } @Override public void say() { System.out.println("Student说话!"); } public static void main(String[] args) { Student student = new Student(); student.fight(); } }
/*
输出结果
Student战斗!
Person战斗!
Student说话!
*/