According to the famous book Head first Java Page 661:
"Garbage Collector doesn't go inside String pool.
"
After reading about the similar questions on SO, i have found mixed answers like:
- Garbage collection of String literals is same as normal objects. Read this
- Some answers say the opposite. Read answer here.
My Questions are:
How were the string literals garbage collected in Java 6 and before ?
And since in Java 7 , string literals will be created on heap, how the garbage collection of string literals will be different in Java 7 as compared to the java 6?