首页 > 代码库 > private 与 super

private 与 super

public class Person {
    private String name;
    private int age;
}
public class Student extends Person {
    public void sayHi() {
        super.name = "";//报错,父类的属性是私有的,不允许子类访问
    }
}

 

private 与 super