June 2004
Intermediate to advanced
848 pages
21h 28m
English
Inner local classes are perhaps the simplest of the nested classes to write, understand, and use. The following table shows how to create an inner local class. You simply write the declaration of your class in the usual way, and put it inside (local to) a block. The block almost always instantiates an object of the inner class.
Information on the local class is shown in Table 12-3.
Table 12-3. Local class
|
Java term |
Description |
Example code |
|---|---|---|
|
Local class |
This is an inner class. It is local to a block, typically within a method. |
void myMethod() { class MyLocal { /*code*/ void something() { } } MyLocal m = new MyLocal(); foo( m );} |
A local ...
Read now
Unlock full access