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 is struts in java?
What is use of static in java?
What is number data type?
What are some characteristics of interference class?
What is a parameter in java?
Can we override the overloaded method?
Can inner class extend any class?
What is difference between an object and a class?
What is the java virtual machine?
What are different types of control structures?
What happens to the Exception object after handling an exception?
What is the method to expand and collapse nodes in a jtree?
How finally used under exception handling?
What is the significance of listiterator?
Explain about abstract classes in java?