java.lang.StringBuffer
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.
Some methods of StringBuffer class
indexOf(String str, int fromIndex): It returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
insert(): Inserts the string representation of the Object (like boolean, int, char, etc) argument into this character sequence.
insert(int index, char[] str, int offset, int len): It inserts the string representation of a subarray of the str array argument into this sequence.
insert(int dstOffset, CharSequence s, int start, int end): It inserts a subsequence of the specified CharSequence into this sequence.
lastIndexOf(String str): It returns the index within this string of the last occurrence of the specified substring.
lastIndexOf(String str, int fromIndex): It returns the index within this string of the last occurrence of the specified substring, searching backward starting at the specified index.
length(): It returns the length of this character sequence.
offsetByCodePoints(): It returns the index within this sequence that is offset from the given index by codePointOffset code points.
replace(): It replaces the characters in a substring of this sequence with characters in the specified String.
reverse(): It replace this character sequence by the reverse of the sequence.
setCharAt(): The character at the specified index is set to ch.
setLength(): It sets the length of the character sequence. The sequence is changed to a new character sequence whose length is specified by the argument.
subSequence(): It returns a CharSequence that is a subsequence of this sequence.
substring(int start): It returns a new String that contains a subsequence of characters currently contained in this character sequence.
substring(int start, int end): It returns a new String that contains a subsequence of characters currently contained in this sequence.
toString(): It returns a string containing the characters in this sequence in the same order as this sequence.
trimToSize(): It attempts to reduce the storage used for the character sequence.
Some more Methods of StringBuffer
No comments:
Post a Comment