62,635
社区成员




class A{
private void x() {}
}
class B extends A{
private int x() {
return 0;
}
}
[/quote]
这没什么好争的。从实现的角度,当然基类的方法存在。从语言的角度来说,你可以视作它不存在。[/quote]
JLS7 Page158
A private class member or constructor is accessible only within the body of the top level
class (§7.6) that encloses the declaration of the member or constructor. It is not inherited
by subclasses.[/quote]
是啊,你看不懂我说的意思么
class A{
private void x() {}
}
class B extends A{
private int x() {
return 0;
}
}
[/quote]
这没什么好争的。从实现的角度,当然基类的方法存在。从语言的角度来说,你可以视作它不存在。[/quote]
JLS7 Page158
A private class member or constructor is accessible only within the body of the top level
class (§7.6) that encloses the declaration of the member or constructor. It is not inherited
by subclasses.
class A{
private void x() {}
}
class B extends A{
private int x() {
return 0;
}
}
[/quote]
这没什么好争的。从实现的角度,当然基类的方法存在。从语言的角度来说,你可以视作它不存在。
class A{
private void x() {}
}
class B extends A{
private int x() {
return 0;
}
}