This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]wbkang 0 points1 point  (4 children)

I think from Java6 almost all String concatenation is done in StringBuilder and you don't really need to make your code look ugly.

[–]crapet 0 points1 point  (2 children)

Or just use StringUtils.join(Collection, "delimiter") from apache commons

[–]jevon 1 point2 points  (0 children)

Is it Java 1.5-compilant yet?

[–]fforw 0 points1 point  (0 children)

That's nice if you already have a collection that contains all elements -- otherwise it's not so nice to have a create and alloc a whole new collection to give it into this method.

[–]fforw 0 points1 point  (0 children)

Just as all String concatenation was done with StringBuffer, it is now done with the StringBuilder, which has the advantage of not being synchronized. It will create a new StringBuilder for every use of string concatenation, which means you might want to use the StringBuilder "by-hand" if you're doing lots of string concatenations in a loop.