StringBuilder Class
The StringBuilder class is used for very fast string concatenation. If you use conventional string concatenation then it will run very slow because a string is held in an array. Each concatenation causes the array to increase its size and the memory has to be copied to a new location internally. This is very slow
Represents a mutable string of characters. This class cannot be inherited.
If we want to do a concatenation or any other operation to an existing string say,
string test="malayalam";
i want to add english to the string a .
test.append("english");
so now the string test becomes "malayalamenglish."But the old value in the string test="malayalam" get over writed.
String is immutable.
eg:
string test="malayalam";
test=malayalam+english
test=malayalmenglish..
But here the previous value wont get destroed.Because another memory location is created for the answer test=" malayalamenglish"
No comments:
Post a Comment