ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jon Skeet" <>
Subject RE: cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs
Date Thu, 11 Apr 2002 14:55:33 GMT
> 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

> 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.)


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message