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 are the common uses of "this" keyword in java ?
In multi-threading how can we ensure that a resource isn't used by multiple threads simultaneously?
What are thread groups?
Explain enumeration in java?
Why singleton class is used in java?
What do you understand by garbage collection in Java? Can it be forced to run?
Define max and min heap, also the search time of heap.
who can i handle multiple client in RMI
How do I stop concurrentmodificationexception?
What is the difference between yield() and sleep()?
how to open and edit XML file in Weblogic???
What does system.gc() and runtime.gc() methods do?
What java is used for?
What is the size of boolean variable?
What is the need of transient variables in Java ?