StringBuffer and StringBuilder are two important classes in Java which represents mutable String i.e. the String object, whose value can be changed. Since String is Immutable in Java, any change or operation on String object e.g. converting it to upper or lower case, adding character, removing character or substring all result in a new String object. This can put a lot of pressure on Garbage collector if your application generates lots of throws away String instances, to avoid this issue, Java designer presented initially StringBuffer class and later StringBuilder. When StringBuffer was introduced it has its own problem e.g. it was synchronized and hence was a lot slower.
0 Comments
If you have any doubts,please let me know