Answers and Comments


User Avatar
Written by aleksin


The reason inner class can access only final variable is because the local class instance can remain in memory after the function returns, then it happends the local variables obviously go out of scope, so a copy of them is needed. If the variables weren't final then the copy of the variable in the method could change, while the copy in the local class didn't, so they'd be out of synch.

See Sun Forum: http://forums.sun.com/thread.jspa?threadID=5291833&messageID=10232307


Saved Stories

Sponsored Categories