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 the purpose of using break in each case of switch statement?
what is the purpose of the wait(), notify(), and notifyall() methods? : Java thread
What is a heavyweight component?
What are loops in java?
What are the differences between heap and stack memory in java?
What is a prefix function.write down a code to compute prefix function.
What are inner classes or non static nested classes in java?
Can an object be null?
Can we clone singleton object?
What is string immutability?
What is meant by bytecode?
How to use arraylist in java netbeans?
What two classes are used to read data only?
Which is better list or arraylist in java?
What is the main use of generics in java?