On 13-May-2009, at 09:16, David kerber wrote:
Christopher Schultz wrote:
...
Since a String object is immutable, one should always use a
StringBuffer (preferably a StringBuilder, these days) when you are
constructing strings in a piecemeal fashion, then convert to String
when complete.
This advice is good when constructing a long string in a loop or
across
a long series of statements. If you are just concatenating a bunch of
string together to make a big one in a single statement, go ahead and
use the + operator: the compiler is smart enough to convert the
entire
thing into a StringBuilder (a non-synchronized replacement for
StringBuffer) expression that gets good performance without making
your
code look like crap.
I was wondering about that. It certainly seemed like a good place
for a smart compiler to fix things up, but didn't know if it
actually did or not. I don't do a lot of that, but enough of it
that it becomes a style issue.
If in doubt write a small test case and repeat it for a period of time
and see which one had the most completions. The one with the most
completions is likely to be the most optimal.
André-John
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org