Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage Collection (URGENT)!

 
Hama Kamal
Ranch Hand
Posts: 144
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi folks

from the K&B book (Objects that are created in a method also need to be considered. When a method
is invoked, any local variables created exist only for the duration of the method.
Once the method has returned, the objects created in the method are eligible for
garbage collection.)

my question: does that mean the Objects which are created in method are alos eligible for garbage colleciton?
if so in the below example this Objectis eligible for GC am i right?


and one more thing:
could you please tell me whtat this line is in the above code? as it gives compilation error ,,it looks like abstract method but the class is not abstract ,, so how can we invoke it there? or it's just there to show you that you can invoke some methods??

 
Piyush Joshi
Ranch Hand
Posts: 207
Eclipse IDE Firefox Browser jQuery
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes objects created in main() method will be available for garbage collection as soon as main() ends.

Don't worry about doComplicatedStuff() method call. It is not an abstract method. Its there just as a placeholder for any code that can execute in between, nothing special.
 
Hama Kamal
Ranch Hand
Posts: 144
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Piyush Joshi wrote:Yes objects created in main() method will be available for garbage collection as soon as main() ends.

Don't worry about doComplicatedStuff() method call. It is not an abstract method. Its there just as a placeholder for any code that can execute in between, nothing special.


thanks Piyush ,,, i got it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic