StringBuffers. So I always thought the point of using StringBuffer's instead of String concatenation with += was for speed. It stops... [bayard]
Is this true? That += causes Strings to be interned that wouldn't otherwise be interned? (All constant Strings are typically interned).
I always thought that + and += was just shorthand for using StringBuffer directly. So that
String s = a + b + c;
Was equivalent to
StringBuffer buffer = new StringBuffer(a); buffer.append(b); buffer.append(c); String s = buffer.toString();
I'm afraid I don't have Brett's book so can't lookup the part that Henri's referring to. Is it true that the + or += explicitly interns the Strings? So that it makes this...
StringBuffer buffer = new StringBuffer(a.intern()); buffer.append(b.intern()); buffer.append(c.intern()); String s = buffer.toString();
I've gotta say, I wouldn't have thought so, thats just plain wierd...
2:28:25 PM
|