A String Builder is like a String, but can be modified. String has drawback that once created it can not be modified. To overcome that problem String Buffer and String builder can be used.
Difference between String Buffer and String Builder
‘StringBuffer’ are safe for use by multiple threads(Thread Safe). The methods are synchronized. String Builder is not thread safe.
Where possible, it is recommended that String Builder should be used in preference to StringBuffer as it will be faster in most of the cases.
Important Methods of String Buffer
- Difference between StringBuilder and String Buffer is that StringBuilders method are not synchronized.
- String Builder is mutable which is opposite to String which is Immutable.
- StringBuilder’s equals method is not overriden, Hence it doesn’t compare the value of StringBuilder. As it does in case of String.