> from the top of my head you may have something like this:
> 
> "aaa" + "bbb" -> "aaabbb"

Guaranteed by the JLS.

> "aaa" + "bbb" + z  -> new StringBuffer("aaabbb").append(z).toString()

Yup, I think that's guaranteed too, but it depends on precedence order.

> "aaa" + "bbb" + z + "ccc" -> new
> StringBuffer("aaa").append("bbb").append(z).append("ccc").toString()

If the previous one is guaranteed, this should be:

new StringBuffer ("aaabbb").append(z).append ("ccc").toString();

Certainly that's the case with:

("aaa"+"bbb")+z+"ccc" - I can never remember the Java precedence order, but I 
believe they're equivalent.

> I also remember that in some cases one compiler may use the empty
> StringBuffer ctor instead of the String one.

Yup - that's left up to the compiler.

(A really good compiler would work out some kind of reasonable guess at a 
buffer size too, but I don't know of any that do that.)

Jon

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to