Possible Duplicate:
String, StringBuffer, and StringBuilder
We know that String are immutable where StringBuffer/StringBuilder are mutable. But sometimes we get confused what to use in our code.. the String or StringBuffer/StringBuilder ?? Practically in our maximum code/quick code we use to prefer String than StringBuffer/StringBuilder.
This question is to solve the confusion, if you have any idea & proper reason for that, then please give a reply.
Below is the main difference between these three most commonly used classes.
StringBuilder objects are mutable.
StringBuffer or StringBuilder.
Criteria to choose among String, StringBuffer and StringBuilder
String object is immutable.
single thread, use a StringBuilder because StringBuilder is
unsynchronized.
threads, use a StringBuffer because StringBuffer is synchronized.