Last post Dec 18, 2017 09:53 PM by neoaguil17
Dec 16, 2017 09:18 AM|Puspa@007|LINK
Can anyone please tell me what is the exact Difference between the string and string builder
Dec 16, 2017 06:03 PM|PatriceSc|LINK
This is explained in details in the documentation at
In short, a string is never changed. Instead a new string is created (and its content copied) which can be costly for repeated changes.
StringBuilder is optimized by using more space than needed for the string (which allows to append to an existing string without having to allocate space or to copy data). You even have some control on the size of this underlying buffer.
Dec 18, 2017 08:30 AM|Eric Du|LINK
According to your needs, as far as I know, string object is can't change, it will create a new memory to store the data. String builder it is a dynamically object, it will increase the performance of the memory. If the characters is more, the performance
of using string builder is better than string.
Here is a detailed tutorial about the difference between string and string builder, please check:
Difference Between String and Stringbuilder in C#:
Dec 18, 2017 09:53 PM|neoaguil17|LINK
The main difference is that "stringbuilder" is faster than "string". If you have to join many strings you have to use stringbuilder .
For example, in the code..
public class Main
public static void main(String args)
long now = System.currentTimeMillis();
System.out.println("slow elapsed " + (System.currentTimeMillis() - now) + " ms");
now = System.currentTimeMillis();
System.out.println("fast elapsed " + (System.currentTimeMillis() - now) + " ms");
private static void fast()
StringBuilder s = new StringBuilder();
private static void slow()
String s = "";
}THE output is: slow elapsed 11741 ms(string)
fast elapsed 7 ms(stringbuilder)
As a result, stringbuilder is faster than string.