Originally posted by Susan Smith:
It says that whenever I make a new String, JVM will put it in String pool.
#1.)
I thought what should happen is more something like this:
1. Create String "0".
2. Create new String "01", "0" no longer referenced by anybody, so it's candidate for garbage collector.
3. And so on.
Whenever you make a new String, the JVM puts it into a special part of memory called the 'String Pool'
That's true for every time around the loop except the very first time; the "0", being a literal, is in the String pool, so it's not collected. All the other ones are.
and compile-time constants (i.e., static final String variables)
Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
Originally posted by Susan Smith:
(2.)
Is doing String manipulation best done using StringBuffer than String?
Will it save memory?
For example, I have a lot of replaceAll statement like this below in my code: