Difference between String and StringBuffer.
Answer Posted / geetha
String and StringBuilder class stores strings. But when you
cannot change a String object after creating one.
eg: String name = "Prasad";
By saying you cannot change the name object means you cannot
change the value in name object internally. When you change
the name object value to something else, a new String object
is creating in memory and assign the new value.
eg: name = "Prasad Reddy";
A new name object is creating in memory and the value
"Prasad Reddy" is assinging to the newly created space.
But StringBuilder class occupies the same space even if you
change the value.
If you are doing string concatenation StringBuilder class is
far better in performance than String class.
You can use StringBuilder's Append() method to use
concatenation.
| Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
What are the 7 types of characters?
v-model life cycle
How do you do math powers in java?
Difference between current previous versions of Java?
What is bean? Where it can be used?
What is unicode datatype?
How does the garbage collector works in java?
Is array serializable java?
What the difference is between execute, execute Query, execute Update?
How are this() and super() used with constructors in java programming?
What will happen to the exception object after exception handling?
What is Recursion Function?
Why are pointers not secure?
What is :: operator in java 8?
What 5 doubled?