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 | 2 No |
Post New Answer View All Answers
how to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state? : Java thread
How do you sort a string in alphabetical order in java?
explain autoboxing in java?
Is array passed by reference in java?
What is a buffer in java?
Can we sort a map in java?
What is the difference between hashmap and hashtable? What is an interface?
What is the maximum size of arraylist in java?
How do I remove a character from a string in java?
How do you do exponents in java?
Explain with example the concept of constant variable in java.
What is flag in java?
what is the difference between preemptive scheduling and time slicing? : Java thread
What are the four pillars of java?
Which is the best sorting technique in java?