What is the data structure of string builder in java ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the data structure of string builder in java ?

for string its a string pool and for StringBuffer its buffer and for StringBuilder ?

28th Jul 2017, 2:07 PM
Priyanka sundar
Priyanka sundar - avatar
1 Answer
+ 1
StringBuilder is just a just an object. It is best used when concatenating lots of Strings. (Or in other words: Building lots of Strings). It works similar to an ArrayList, but optimized for Strings. I recommend it for large toStrings() where a loop is involved. It will heavily improve performance there. Or of course anywhere else with a fair amount of concatenation.
28th Jul 2017, 2:31 PM
Rrestoring faith
Rrestoring faith - avatar