This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori 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