posted 21 years ago
D. An anonymous inner class can access final variables in any enclosing scope
Basically an anonymous class have direct access to all members in the enclosing context whether they are declared as final or not. In the case of local method variables, since the anonymous object can continue to exist longer than local method variables, the anonymous object is not permitted to access local method variables unless the variable is declared final and is assigned a value before the declaration of the local or anonymous class. The JVM can place a copy of the value of the final variable directly into the local or anonymous class so there is no further dependence on the method variable.
Hope that makes sense.
[ November 27, 2002: Message edited by: Roan Nicolas ]