by, 04-26-2012 at 07:38 PM (810 Views)
Few StringBuffer methods has many uses which is being explained by the following program:
String buffer’s current capacity is returned.
String buffer’s length is returned.
3. charAt(int index)
Specified sequence character which is presented by string buffer are returned.
4. setCharAt(int index, char ch)
At specified index, the character of this string buffer has been set to ch
Gets converted to String presenting data which is there in string buffer.
6. insert(int offset, char c)
String presentation is inserted, of char argument, to string buffer.
7. delete(int start, int end)
characters which are present in a StringBuffer’s substring are removed.
8. replace(int start, int end, String str)
Replaces those characters which are present in a StringBuffer’s substring, with characters which are there in the specified String.
In string buffer, character sequence is present which is replaced by sequence reverse.
10. append(String str)
string is appended to this string buffer.
11. setLength(int newLength)
Sets this String buffer’s length.