StringBuilder and StringBuffer are the most commanly used Java classes to handle String, here are some differences:
Differences between StringBuilder and StringBuffer
- StringBuffer is synchronized and hence thread safe. It means two or more threads can’t call the methods of StringBuffer simultaneously.
- StringBuffer is slow because it is thread safe where as StringBuilder is fast.
- StringBuffer was included in very first version of Java API, the JDK 1.0, while StringBuilder was included when JDK 1.5 was released.