Static member types
A static member type is any type defined as a static member of another type.
Nested interfaces, enums, and annotations are always static (even if you don't
use the keyword).
Nonstatic member classes
A “nonstatic member type” is simply a member type that is not declared
static . Only classes can be nonstatic member types.
A local class is a class that is defined and only visible within a block of Java
code. Interfaces, enums, and annotations may not be defined locally.
An anonymous class is a kind of local class that has no meaningful name in the
Java language. Interfaces, enums, and annotations cannot be defined
The term “nested types,” while a correct and precise usage, is not widely used by
developers. Instead, most Java prorammers user the much vaguer term “inner class.”
Depending on the situation, this can refer to a nonstatic member class, local class,
or anonymous class, but not a static member type, with no real way to distinguish
Fortunately, although the terminology for describing nested types is not always
clear, the syntax for working with them is, and it is usually clear from context which
kind of nested type is being discussed.
Let's move on to describe each of the four kinds of nested types in greater detail.
Each section describes the features of the nested type, the restrictions on its use, and
any special Java syntax used with the type. These four sections are followed by an
implementation note that explains how nested types work under the hood.
Static Member Types
A static member type is much like a regular top-level type. For convenience, how‐
ever, it is nested within the namespace of another type. Static member types have
the following basic properties:
• A static member type is like the other static members of a class: static fields and
• A static member type is not associated with any instance of the containing class
(i.e., there is no this object).
• A static member type can access (only) the static members of the class that
• A static member type has access to all the static members (including any
other static member types) of its containing type.