Tuesday, March 19, 2013

A Note on String, StringBuffer, StringBuilder

When String (an immutable [not modifiable] type) construction or modification involving dynamic values (whose values are not known at compile time) is required by a single thread, the mutable StringBuilder will perform faster than StringBuffer.  The reason for the performance hit is likely that StringBuffer is thread-safe through synchronization.  StringBuilder is also mutable but not thread-safe, hence the faster predicted performance.

No comments:

Post a Comment