1. 程式人生 > >private 與 super

private 與 super

super nds bsp per 屬性 pre cnblogs div ext

public class Person {
    private String name;
    private int age;
}
public class Student extends Person {
    public void sayHi() {
        super.name = "";//報錯,父類的屬性是私有的,不允許子類訪問
    }
}

private 與 super