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 does this () mean in java?
What is hashing in java?
What is a double vs float?
Is it possible to compare various strings with the help of == operator? What are the risks involved?
Can we declare register variable as global?
How to display arraylist values in java?
How to split arraylist elements in java?
What does the ‘static’ keyword mean? Is it possible to override private or static method in java?
When should I use singleton?
What are thread priorities and importance of thread priorities in java?
Tell me a few examples of final classes defined in Java API?
Is there any limitation of using inheritance?
Variable of the boolean type is automatically initialized as?
How will you reverse a link list without using recursion?
Can static method access instance variables ?