+ 1

What is the difference between the StringBuffer and StringBuilder class?

When are they to be used?

14th Mar 2020, 8:56 AM
Michael Solomon
Michael Solomon - avatar
5 Respostas
+ 4
I have answered this sometime back. Hope you find it useful. https://www.sololearn.com/discuss/2141134/?ref=app
14th Mar 2020, 9:08 AM
Avinesh
Avinesh - avatar
+ 2
StringBuffer is synchronized and StringBuilder is not synchronized.
14th Mar 2020, 9:10 AM
Prathvi
Prathvi - avatar
+ 1
It depends on what you're trying to achieve with either one. If you desire to work with faster speed then the StringBuilder class is ideal. If you desire thread safety then the StringBuffer class is ideal. More answers are welcome of course.
14th Mar 2020, 9:09 AM
Michael Solomon
Michael Solomon - avatar
+ 1
Thanks Avinesh! I will check out the link.
14th Mar 2020, 9:12 AM
Michael Solomon
Michael Solomon - avatar
+ 1
I just checked out the link and the answer given is detailed. Thanks! Prathvi thanks for your answer too
14th Mar 2020, 9:15 AM
Michael Solomon
Michael Solomon - avatar