- class Person
- {
- private String name;
- Person(String name){
- this.name = name;
- }
- public String getName(){
- return name;
- }
- }
- class Student extends Person
- {
- Student(String name){
- super(name);
- }
- }
- class java
- {
- public static void main(String[] args){
- Student s = new Student("haha");
- System.out.println(s.getName());
- }
- }
复制代码
就是如上代码,为什么子类继承的方法能够调用父类的私有成员?
|
|