string vs stringbuilder 1

string vs stringbuilder

String is immutable and thread safe
String builder mutable and not thread safe

Here is what the above code is Doing:
1. It creates a StringBuilder object.
2. It appends the string “Hello” to the StringBuilder object.
3. It appends the string “World” to the StringBuilder object.
4. It converts the StringBuilder object to a String object.
5. It prints the String object.

Similar Posts