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


Please Help Members By Posting Answers For Below Questions

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

615


How do you sort a string in alphabetical order in java?

629


explain autoboxing in java?

680


Is array passed by reference in java?

666


What is a buffer in java?

666






Can we sort a map in java?

669


What is the difference between hashmap and hashtable? What is an interface?

632


What is the maximum size of arraylist in java?

591


How do I remove a character from a string in java?

600


How do you do exponents in java?

650


Explain with example the concept of constant variable in java.

749


What is flag in java?

609


what is the difference between preemptive scheduling and time slicing? : Java thread

630


What are the four pillars of java?

737


Which is the best sorting technique in java?

620