1.

StringBuffer vs StringBuilder in Java

Answer»

StringBuffer class which is related to class STRING that GIVES most of the usage of strings. StringBuffer is a mutable, expandable and WRITABLE SEQUENCE of characters.

StringBuilder is a class whose objects are similar to String objects barring that they can be CHANGED. The size and matter of the sequence of characters can be modified through method calling statements.

Basis
StringBuffer
StringBuilder
Introduction
StringBuffer in Java was introduced in JDK 1.0.
StringBuilder in Java was introduced in JDK 1.5.
Synchronization
Every method present in StringBuffer class is synchronized.
Every method present in StringBuilder class is not synchronized.
Performance
Performance is low
Performance is relatively high
Thread Safe
StringBuffer Object is thread safe.
StringBuilder Object is not thread safe.


Discussion

No Comment Found