Possible Duplicate:
StringBuilder and StringBuffer in Java
Criteria to choose among StringBuffer and StringBuilder
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re definitely using Java 5 or higher, and you definitely don’t need to share the object between threads (I can’t remember ever needing to do so),
StringBuilderis a better bet.Basically you should almost always use
StringBuilderwhen you can, to avoid pointless synchronization. Admittedly the way most VMs handle uncontended synchronization is extremely efficient, but if you don’t need it in the first place…