Static nested class has access to private constructor of outer class

Eugene

It is stated that:

A static nested class interacts with the instance members of its outer class (and other classes) just like any other top-level class. In effect, a static nested class is behaviorally a top-level class that has been nested in another top-level class for packaging convenience.

So how to explain this static nested class has access to private constructor of its enclosing class?

Ian Roberts

So how to explain this static nested class has access to private constructor of its enclosing class?

Because the scope and accessibility of any private member (field, constructor or method) is the complete body of its declaring class, including any nested classes.

From the Java Language Specification section 6.6.1:

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Static nested class has access to private constructor of outer class

From Dev

Static nested class has full access to private outer class members?

From Dev

Why would I combine a private constructor with a static nested class?

From Dev

Initialization of static variables in a class which has a private constructor

From Dev

Java: reference outer class in nested static class

From Dev

Access outer class in inner nested class

From Dev

Inner class access to outer class nested enum

From Dev

Access outer class in inner nested class

From Dev

Inner class access to outer class nested enum

From Dev

nested class has a static variable?

From Dev

Class with private constructor and static array of itself

From Dev

Accessing static methods of inner class from an outer class nonstatic constructor

From Dev

base class 'QAbstractListModel' has private copy constructor

From Dev

Referring to static nested class object from outer class

From Dev

Referring to static nested class object from outer class

From Dev

Nested class AsyncTask can't modify Outer Class static objects

From Dev

Can GSON handle static private nested class

From Dev

How I can access a private static member variable via the class constructor?

From Dev

PHPUnit mock class that has named static constructor

From Dev

Access outer class instance using nested class instance stored in a variable?

From Java

Java static constructor access in child class

From Dev

How to access private static class member inherited from a template class?

From Dev

How does static inner class can access all the static data members and static member function of outer class?

From Dev

Static field is initialized later when the class has a static constructor

From Dev

Java - Can a class access a private field of its nested class?

From Dev

Java - Can a class access a private field of its nested class?

From Dev

How a friend class can access a private member of a nested class?

From Dev

How to access private static variable in static member function of another class?

From Dev

Public constructor of a private class

Related Related

  1. 1

    Static nested class has access to private constructor of outer class

  2. 2

    Static nested class has full access to private outer class members?

  3. 3

    Why would I combine a private constructor with a static nested class?

  4. 4

    Initialization of static variables in a class which has a private constructor

  5. 5

    Java: reference outer class in nested static class

  6. 6

    Access outer class in inner nested class

  7. 7

    Inner class access to outer class nested enum

  8. 8

    Access outer class in inner nested class

  9. 9

    Inner class access to outer class nested enum

  10. 10

    nested class has a static variable?

  11. 11

    Class with private constructor and static array of itself

  12. 12

    Accessing static methods of inner class from an outer class nonstatic constructor

  13. 13

    base class 'QAbstractListModel' has private copy constructor

  14. 14

    Referring to static nested class object from outer class

  15. 15

    Referring to static nested class object from outer class

  16. 16

    Nested class AsyncTask can't modify Outer Class static objects

  17. 17

    Can GSON handle static private nested class

  18. 18

    How I can access a private static member variable via the class constructor?

  19. 19

    PHPUnit mock class that has named static constructor

  20. 20

    Access outer class instance using nested class instance stored in a variable?

  21. 21

    Java static constructor access in child class

  22. 22

    How to access private static class member inherited from a template class?

  23. 23

    How does static inner class can access all the static data members and static member function of outer class?

  24. 24

    Static field is initialized later when the class has a static constructor

  25. 25

    Java - Can a class access a private field of its nested class?

  26. 26

    Java - Can a class access a private field of its nested class?

  27. 27

    How a friend class can access a private member of a nested class?

  28. 28

    How to access private static variable in static member function of another class?

  29. 29

    Public constructor of a private class

HotTag

Archive