补充super

public class Person {
protected String name="lisi";
}

public class Student extends Person {
private String name="linsi";
public void test(String name){
System.out.println(name);
System.out.println(this.name);
System.out.println(super.name);
}
}

public class Application {
public static void main(String[] args){
Student student=new Student();
student.test("李四");
}
}
运行结果:
李四
linsi
lisi
Process finished with exit code 0

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