Thomas A. Alspaugh
Nested Classes

Under Construction

A nested class may be any of the following:

member class/interface
A class/interface whose definition is directly enclosed in that of another class or interface. Directly enclosed in D means without also being enclosed within another member class or interface of the same class or interface D; children, not grandchildren or further descendants.

An attribute or method of a member class hides any member of the same kind and name in the member class's scope.

A member class can only be either public, protected, or private.

A member class cannot have static members other than compile-time constand fields.

It appears that a member class may be declared static, in which its constructor can be called without using a specific member of the enclosing class, and the member class still has access to the enclosing class's attributes and methods. This is the only situation in which a class can be declared static.

A non-static member class is also a kind of inner class.

local class
A named class declared inside a block. The scope of the class is its own definition plus the rest of the block.
anonymous class
A class declared inside an expression. There are a range of restrictions, such as that the class can have no explicit constructor.

The fully-qualified name of a non-anonymous nested class is its containing class's fully-qualified name, a dot, and the nested class's name.

An instance of a static nested class is constructed by calling its constructor. An instance of a non-static nested class N can only be constructed within an instance i of its containing class, and its constructor is called as if it were a method of i, for example as i.N().

A member of a class or interface E is a field, class, interface, or method declared in E.

An inner class is a non-static nested class. A nested class can't have static initializers or member interfaces, or static members that are not compile-time constant fields. An inner class inherits its parent class's fields (but not methods).

flip bgunflip