What is the difference between StringBuffer and StringBuilder class?

Questions by sujatham   answers by sujatham

Showing Answers 1 - 12 of 12 Answers

StringBuilder is introduced in java 1.5

StringBuffer is designed to be thread-safe and all public methods in StringBuffer are synchronized. StringBuilder does not handle thread-safety issue and none of its methods is synchronized.

StringBuilder has better performance than StringBuffer under most circumstances.

StringBuilder is a feature of Java 5


Methods in StringBuffer are Synchronized & thread safe.
Methods in StringBuilder are not Synchronized & not thread safe.

If you want faster access use StringBulder. If you want your string to be thread safe, use StringBuffer.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions