Friday, May 29, 2009

Differences between StringBuffer and String

StringBufferString
It provides a mutable character sequence. It provides an immutable character sequence.
It is possible to insert characters and substrings in the middle or at the end of the string.It is not possible to insert characters and substrings in the middle or at the end of the string.
It reserves room for 16 characters without reallocation.It does not reserve room for characters.
It uses the ensureCapacity(), delete(), deleteCharAt(), append(), insert(), and reverse() methods.It is not possible to use these methods on strings because they are immutable.

No comments:

Post a Comment