String builder vs String buffer | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

String builder vs String buffer

explain the differences in Java ??

10th Nov 2016, 6:09 PM
Avinash
Avinash - avatar
1 Answer
+ 3
great question... both are used to create mutable string. DIFFERENT:::-- string buffer is synchronized..so it is thread safe means two thread can't call method of string buffer simultaneously. string builder is not synchronised. string builder is faster. string buffer is bit slower. so string builder has performance advantage. ----- which to use?? if you create string which only modified by single thread then use string builder. if your string is modified by multiple thread then use string buffer.
10th Nov 2016, 6:34 PM
Harish Nandoliya
Harish Nandoliya - avatar