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 / parameswaran m

The StringBuilder one is slightly more efficient and uses
less memory. In practice, it is unlikely to make enough of a
difference to matter either way.

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can a method be static?

520


What is the difference between a static and a non-static inner class in java programming?

522


When arithmeticexception is thrown?

575


Why map is used in java?

569


When a thread is executing synchronized methods , then is it possible to execute other synchronized methods simultaneously by other threads?

563






Why put method is idempotent?

454


What is widening and narrowing in java? Discuss with an example.

554


Why singleton is not thread safe?

561


what is instanceof operator used in java?

587


what is optional in java 8?

549


What is variable and example?

513


What is the difference between interface & abstract class?

555


What are different exception types exceptions available in java ?

473


Explain thread life cycle in java?

587


What are the advantages of exception handling?

550