File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

method-local inner classes

 
Harry Tuttle
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm just preparing for the scjp/ocp and in the chapter about the inner classes (SCJP Sun Certified Programmer for Java 6 Study Guide I, p. 670) there is this code example:



I understand all lines, but my question is: It's right that the inner object will be carbage collected (but with no garantee) after the method doStuff() completes?

 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the variable inner goes out of scope at the end of the method, there are no other references to the object and the object is not passed out of the method, then yes, it's eligible for garbage collection.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic