RSS Feed for This PostCurrent Article

Java: StringBuilder vs StringBuffer

StringBuilder is introduced starting JDK 1.5. There are few differences for them

  • 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.

So, use StringBuilder if it is not used by multiple threads.

Trackback URL

Sorry, comments for this entry are closed at this time.