A local class is defined within a block a Java code, typically a method, but also static and instance initializers. |
The local class is only visible within the block of code in which its defined. |
It can use any final (can't be overriden by subclass) local variables or method parameters within its scope. |
Syntax: just declare the class and use it entirely within one block, such as a method. (Note that use of "final" modifier is liberalized.) |
Unlike member classes, local classes can refer to local variables of block they're defined in. |
Typical use of local classes is to define "event listeners". |
There are also anonymous local classes, introduced without a name. Special syntax not covered here. |