File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes GarbageCollection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "GarbageCollection" Watch "GarbageCollection" New topic


G Nadeem
Ranch Hand

Joined: Apr 25, 2003
Posts: 48
ur help plz...

is the object created at line 2 elligible for GC after line 4 executes.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Yes. Remember, Strings are immutable objects. Therefore, performing a concatenation operation creates a brand new String. It does not reference the existing Strings that were used in the concatentation.
Therefore, the object is eligible for garbage collection after line 4.
I hope that helps,

SCJP Tipline, etc.
G Nadeem
Ranch Hand

Joined: Apr 25, 2003
Posts: 48
thnx v much Corey...
I agree. Here's the link:
subject: GarbageCollection
It's not a secret anymore!