posted 14 years ago
Hi,
I understand that method local inner classes (i.e. inner classes defined from within a method) can't access the method's local variables, since the local variables live on the stack and are bust after the method is done, but the instance of the method local inner class could live much longer (since a reference could be returned and used).
But I also read that while the method local inner classes can't access a local variable, there is an exception to the rule - that the method local inner class could access a "final" local variable. How come? Don't all local variables including "final" local variables live on the stack? So how can a method inner classe's instance access a "final" local variable, even though it can't access non-final local variables.
Could someone please throw some light on this?
Thanks