补充Super 2.0

public class Person {
protected String name="lisi";
public void print(){
System.out.println("Person");
}
}

public class Student extends Person {
private String name="linsi";

@Override
public void print() {
    System.out.println("Student");
}
public void test1(){
    print();//Student
    this.print();//Student
    super.print();//Person
}

}

public class Application {
public static void main(String[] args){
Student student=new Student();
student.test1();
}
}
运行结果:
Student
Student
Person

posted @ 2025-04-02 20:19  骆驼刺破仙人掌007  阅读(6)  评论(0)    收藏  举报