Can a subclass access parent class private members if both the classes are in the same package
我正在读一个Java文档,上面写着
A subclass inherits all of the public and protected members of its
parent, no matter what package the subclass is in. If the subclass is
in the same package as its parent, it also inherits the
package-private members of the parent. You can use the inherited
members as is, replace them, hide them, or supplement them with new
members
它表示如果子类位于同一个包中,则子类可以访问父类的私有成员。我已经尝试过了,我无法访问子类中父类的私有成员
不,它表示
If the subclass is in the same package as its parent, it also inherits the package-private members of the parent