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 Soft Skills this week in the Jobs Discussion 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

Asanka Vithanage
Ranch Hand

Joined: Oct 24, 2008
Posts: 59
if we create a method local inner class object
Is it eligible for garbage collection after method completion.?


SCJP 1.5 (94%)
Punit Singh
Ranch Hand

Joined: Oct 16, 2008
Posts: 952
Yes, until you pass this object reference outside the method.


SCJP 6
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9317
    
  17

If you create a Method Local Inner class, it is NOT eligible for garbage collection. If you create an instance of the Method Local Inner class, that will be eligible for GC after the method call returns. But there is a twist here. You cannot declare a method local inner class as return type of a method. So you have to use a base type of the method local inner class as the return type of the method.



SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: method local inner class