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 / debapriya maity
The first one is faster
Second code snippets:3 objects are created
1:s = "Hello Mom"
2:,I mean Mom
3:Hello Mom,I mean Mom
| Is This Answer Correct ? | 5 Yes | 1 No |
Post New Answer View All Answers
What is the exception hierarchy in java?
What isan abstract class and when do you use it?
What is passed by reference and pass by value ?
How do you compare arrays in java?
Why string is not a wrapper class?
What is the reason behind using constructors and destructors?
What is formatted output in java?
Garbage collection in java?
Why is the main method declared static?
Explain the selection sort algorithm and state its time complexity?
What is assembly used for?
Define how does a try statement determine which catch clause should be used to handle an exception?
How do you square a number?
Which one will take more memory: an int or integer?
Do I need java on my computer?