refers to the current object instance.
When using non-
inner classes, there is a
associated with the inner class and with its enclosing class.
is used within the scope
of the inner class,
refers to the instance of the inner class.
is used outside the scope of the inner class, but within the scope of the outer class,
refers to the outer class.
can also be used to access the instance of the enclosing scope (outer class).
can be used within
to reference the
The InnerThis program
provides an example of using
within inner classes.
The extent of the context of a definition.
Local inner classes
are inner classes that are declared local to a block of code (e.g., local to a method).
Local inner classes are not tied to an enclosing scope. Instead, they are treated as local variables.
As such, they may not be declared as
. Local inner classes may only access the local variables or method parameters of the code block in which they are defined.
Furthermore, these variables or parameters must be declared as
and assigned a value before being used.
The LocalInner program
illustrates the use of local inner classes.
Local inner class:
An inner class that is declared local to a block of code.