Home           J2EE Concepts           JMS           Java Language           Contact           Back           Next           Bookmark this Page          










Some useful tips related to:
 - health & fitness
 - vehicle care
 - cooking
 - misc household tasks

String Vs. StringBuffer


String is immutable, whereas StringBuffer is not!
This means, if you've to perform manipulations then use StringBuffer, otherwise String would do just fine.

Operations performed on StringBuffer are much faster.

Since String is immutable, therefore, any operations performed on String would lead to creation of new String variables in memory.

StringBuffer is said to be thread safe. However, in my opinion it really doesn't matter because String is immutable, so it is not supposed to change; and if it is not supposed to change then there is no point in thinking over advantages of StringBuffer in terms of thread safety.