java stringbuffer code example

Example 1: stringbuffer vs stringbuilder java

The StringBuffer and StringBuilder class both produces mutable string objects.
 The main difference between them is that StringBuffer is thread safe;
 StringBuilder is not thread safe.

Example 2: stringbuffer javascript

Internet Explorer is the only browser which really suffers from this in today's world. (Versions 5, 6, and 7 were dog slow. 8 does not show the same degradation.) What's more, IE gets slower and slower the longer your string is.

If you have long strings to concatenate then definitely use an array.join technique. (Or some StringBuffer wrapper around this, for readability.) But if your strings are short don't bother.

Example 3: what is stringbuffer

StringBuffer class produce mutable string object
and it is thread safe.
We are using StringBuffer when we are doing parallel
testing since it is a thread safe.