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
What is use of static method?
Explain where variables are created in memory?
What is the difference amongst jvm spec, jvm implementation, jvm runtime ?
What is array command?
What are inner classes or non static nested classes in java?
Can an abstract class be a final class?
How to declare objects of a class ?
What are the properties of thread?
Name few "optional" classes introduced with java 8 ?
What are the differences between heap and stack memory?
What is diamond operator in java?
why we use merge option in hybernate pls give a ex snippet
Can we have two methods in a class with the same name?
What is t type java?
How do you generate random numbers in java?