aspose file tools*
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "method local inner class" Watch "method local inner class" New topic
Author

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
Sheriff

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
sscce.org
 
jQuery in Action, 2nd edition
 
subject: method local inner class