This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes method local inner class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "method local inner class" Watch "method local inner class" New topic

method local inner class

Shiva Mohan
Ranch Hand

Joined: Jan 05, 2006
Posts: 477
i thought final varaibles of enclosing class only accessible in method local inner class like method local variable(y1)
but i1 and i are accessing inside inner class.Why?
marc weber

Joined: Aug 31, 2004
Posts: 11343

It's only the non-final local (method) variables that the local class cannot use. The reason is that local (method) variables are destroyed when the method exits. If these are final, then their values can be copied into any instances of the local class.

But the local class can use non-final variables outside the method (that is, members of the enclosing class).

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Don't get me started about those stupid light bulbs.
subject: method local inner class
Similar Threads
Another puzzling question
Inner Class Object
Nested/Inner classes Example program
doubt Method local inner class
Local Class Doubt