File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 15376
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: 60810

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] [Bear's FrontMan] [About Bear] [Books by Bear]
jQuery in Action, 2nd edition
subject: String concatenation
Similar Threads
difference between JAXRPC and SOAP
JSF for part 1
Nanhesru Ningyake