scope of private constructor in Nested Class

前端 未结 3 1618
慢半拍i
慢半拍i 2020-12-14 16:09

This is more of a puzzle than question. I have the following code:

public class PrivateBaseConstructor {
    public static class BaseClass {
                


        
3条回答
  •  猫巷女王i
    2020-12-14 16:57

    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.

    http://docs.oracle.com/javase/specs/jls/se7/html/jls-6.html#jls-6.6.1

提交回复
热议问题