/* related posts with thumb nails */

StringBuffer class:

StringBuffer is a peer class of String class. While String creates strings of fixed length, StringBuffer creates strings of flexible length that can be modified in terms of both length and content. We can insert characters into or delete characters from a string. The few differences between String and StringBuffer are listed below.

· StringBuffer objects are mutable.

· It provides functions like setCharAt(), deleteCharAt() and etc.

· It allocates extra 16 bits of memory

· It can be treated as a dynamic string.

StringBuffer can be initialized as follows

StringBuffer s1 = new StringBuffer(“abcd”)


used for the concatenate the string in string buffer. This is better to use for dynamic string concatenation.


used to insert any string or character at the specified position in the given string.


used to reverse the string present in string buffer.


used to set the specified character in buffered string at the specified position.


used to get the character at the specified position of the given string.


used to get the sub string from the buffered string


used to delete the specific character at a given position from the buffered string


used to finding the length of the buffered string.


used to delete multiple character at once from n position to m.


used to know the capacity of the object i.e. Number of characters + 16.

Related Topics:


Post a Comment