When I define a StringBuffer variable with new, this string is not added to the String pool, right?
StringBuffer
new
Now, when I define another String
String
buf.append("XXX") followed by buf.toString(), and then returning the string to the pool. With the pool in place, only one StringBuffer object is ever allocated.
buf.append("XXX")
string