Difference between String & StringBuffer
Answer Posted / niranjanravi
String objects are constants and immutable where as
StringBuffer objects are not.StringBuffer Class supports
growable and modifiable string where as String class
supports constant strings. Strings once created we cant
modify them. Any such attempt will lead to the creation of
new strings.Where as StingBuffer objects after creation
also can be able to delete oo append any characteres to
it.String values are resolved at run time where as
StringBuffer valuesc are resolved at compile time.So if you
know the exact size of the string to be appended it is
better to go for String objects.
Is This Answer Correct ? | 194 Yes | 19 No |
Post New Answer View All Answers
What is a protected method?
Find the value of a specified element of the array arr[i] where 0 <= i <= n-1
What methods are used to get and set the text label displayed by a button object?
What is string :: npos?
Can an interface have a constructor?
What is connection class in java?
I want to persist data of objects for later use. What is the best approach to do so?
What is the purpose of object oriented programming?
What is multi-catch block in java?
What is boolean logic?
How do you write a scanner class in java?
Does treeset allow null in java?
What are the main concepts of oops in java?
what are three ways in which a thread can enter the waiting state? : Java thread
What is considered an anti pattern?