This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I have one doubt regarding the String object and String literals .where the String object and String literals are stored. In String pool i.e String table or In Heap.Both String object and String literal are eligible for the garbage collection or not ??
Anything that is object and "only object" will be eligible for Garbage collection.
Joined: Aug 11, 2007
Originally posted by Gitesh Ramchandani: Anything that is object and "only object" will be eligible for Garbage collection.
No !!! String literals are objects. Unlike most objects,they always have a reference to them from the String Literal Pool. That means that they always have a reference to them and are, therefore, not eligible for garbage collection. Strings, Literally