Difference between StringBuffer and StringBuilder

There is a subtle yet important difference between the StringBuffer and StringBuilder. StringBuffer is synchronized when it has to access/modify its contents, where as StringBuilder is not. A StringBuilder object is not safe to be shared across multiple threads.

It is much efficient to make use of StringBuilder when the StringBuilder object is not shared between multiple threads.

StringBuilder was introduced in JDK 1.5.


Popular posts from this blog

The mysterious ORA-03111 error

Note on allocationSize parameter of @SequenceGenerator while using JPA

Creating a Collection with a single element