子类不能继承父类的私有成员为什么还能输出Age? 个人觉得子类没有继承父类的age属性就没有age属性。
class ExtendsTest2{
public static void main(String[] args){
Zi z = new Zi(6);
System.out.println(z.getAge());
}
}
class Fu{
private int age;
void setAge(int age){
this.age = age;
}
int getAge(){
return age;
}
Fu(int age){
this.age = age;
}
}
class Zi extends Fu{
Zi(int age){
super(age);
}
}
|
|