关于java:如果两个类都在同一个包中,子类是否可以访问父类私有成员

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

package-private(无修饰语)与private修饰语(private修饰语)不同。有关差异,请参阅https://docs.oracle.com/javase/tutorial/java/javaoo/accesscontrol.html。


package-privateprivate成员之间存在差异。除了类本身,任何人都不能访问私有成员。但是,软件包私有成员是那些仅属于该特定软件包的private成员,并且该特定软件包中的任何成员都可以访问这些成员。

enter image description here