The moose likes HTML, CSS and JavaScript and the fly likes String concatenation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "String concatenation" Watch "String concatenation" New topic

String concatenation

Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
It is know that building strings with += is bad practice since it is slow and we should be using Arrays with join.

Does anyone know where the performance gain begins. [Like the StringBuilder in C# sees gains starting around 10 concats]

I plan on running some tests later on today. I was hoping someone had some insight.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63852

I've never done any tests myself. I figure with everything else that is going on, any performance difference would just be noise unless you are talking on the scale of hundreds or thousands.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: String concatenation
It's not a secret anymore!