String buffer is a thread-safe, mutable sequence of characters. A string buffer is like a String, but can be modified. At any point in time it contains some particular sequence of characters, but the length and content of the sequence can be changed through certain method calls.
For example, if z refers to a string buffer object whose current contents are "start", then the method call z.append("le") would cause the string buffer to contain "startle", whereas z.insert(4, "le") would alter the string buffer to contain "starlet".
Popular methods on String buffer are :
1. insert
2. append
3. capacity
4. delete
for more information on StringBuffer refer below
Oracle Docs http://docs.oracle.com/javase/6/docs/api/java/lang/StringBuffer.html
.
Whereas String is a immutable sequence of characters and differs from StringBuffer which is mutable.
For example, if z refers to a string buffer object whose current contents are "start", then the method call z.append("le") would cause the string buffer to contain "startle", whereas z.insert(4, "le") would alter the string buffer to contain "starlet".
Popular methods on String buffer are :
1. insert
2. append
3. capacity
4. delete
for more information on StringBuffer refer below
Oracle Docs http://docs.oracle.com/javase/6/docs/api/java/lang/StringBuffer.html
.
Whereas String is a immutable sequence of characters and differs from StringBuffer which is mutable.
No comments :
Post a Comment