Possible Duplicate:
java String concatenation
StringBuilder vs String concatenation in toString() in Java
I ve read some articles about append() is much faster than +, but what is the reason ,and why would we use + over append()at all? Thanks!
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.
+creates new intermediateStringojectss as Strings are immutable in Java where asStringBuffer‘sappend()works on the same string and that is why it is considered faster. However, you should useStringBuilderfrom java 5 on wards as it is said to be faster thanStringBufferas it’s methods are notsynchronizedlike StringBuffer.This is high level theoritical explanation. For more specific details look at String concatenation: concat() vs "+" operator post.