Discuss / Java / 补充一点内部类private修饰符的作用域

补充一点内部类private修饰符的作用域

Topic source

a_bumpy_night

#1 Created at ... [Delete] [Delete and Lock User]

包含内部类的外部类,在这个外部类里面,也可以使用内部类本身private的字段。

Otherwise, if the member or constructor is declared private, then access is permitted if and only if it occurs within the body of the top level class (§7.6) that encloses the declaration of the member or constructor.

具体讨论见

https://stackoverflow.com/questions/1801718/why-can-outer-java-classes-access-inner-class-private-members


  • 1

Reply