difference between string stringbuffer and stringbuilder in java gfg code example
Example 1: stringbuilder vs stringbuffer
They both mutable, they are exactly same but
String buffer is thread safe so it runs slower
than String builder.
We are using StringBuffer when we are doing parallel
testing since it is a thread safe.
Example 2: string vs stringbuilder vs stringbuffer
String vs StringBuilder vs StringBuffer
STRING STRINGBUFFER STRINGBUILDER
Storage String Pool Heap Heap
Modifiable Immutable Mutable Mutable
Thread Safe YES YES NO
Performance FAST VERY SLOW FAST