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.

Comments

Popular posts from this blog

Gotchas with DBCP

A note on Java's Calendar set() method

The mysterious ORA-03111 error