StringBuilder s = new StringBuilder("Hello
Mom");s.append(",I mean,Mother");
Response.Write(s.ToString());
String s = "Hello Mom";
s+ = ",I mean Mom";
Response.Write(s);
Which is faster ? which uses the most memory?
Answer Posted / prasanta khandai
Actually what happens if u add two strings like second one,
then internally it uses the String Builder to call the
append method to add and it converted into the strings again.
so first one is the faster as it appended right ways.
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
What is adapter in java?
Explain the purpose of garbage collection in Java?
What is thread count in java?
What is the purpose of sizeof operator?
Can we restart a dead thread in java?
What does this () mean in constructor chaining concept?
Is null keyword in java?
What is difference between filereader and bufferedreader?
What is exception hierarchy in java?
How do you sort data in java?
What is the purpose of a transient variable?
What is extension method in java?
What is the history of java?
Why bytecode is called bytecode?
What is collections framework?