• Post Reply Bookmark Topic Watch Topic
  • New Topic

When will the object get garbage collected  RSS feed

 
Chandra Bairi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in this particular code at which step will the object get garbage collected
a:String s = new String("hi");
B:s=null;
c:
a)
B)
c)
Thanks in advace.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
at some point after you set it to null but before the JVM terminates, it is impossible to be more specific than that.
 
Chandra Bairi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is can i say that the object is eligible for garbage collection "AFTER EXECUTING" step b
 
Tom Wolve
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!