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


Please Help Members By Posting Answers For Below Questions

What do you understand by the bean persistent property?

549


What is a local, member and a class variable?

573


How do you compare arrays in java?

495


What is an array length?

495


how to create daemon thread in java?

600






What is the purpose of garbage collection in java?

649


Why parsing is done?

498


What is the benefit of inner / nested classes ?

521


What is a linkedhashmap java?

543


What invokes a thread's run() method in java programming?

561


Is java developer a good career?

548


Explain when we should make an instance variable private.

603


What is linkedlist in java?

500


How does a for loop work java?

536


What is casting in java programming?

574