StringBuffer class Methods in Java Part - I

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


appendCodePoint():  It appends the string representation of the codePoint argument to this sequence. 


append()Appends the string representation of the Object argument. The overall effect is exactly as if the argument were converted to a string by the method.


append(char[] str, int offset, int len) It appends the string representation of a subarray of the char array argument to this sequence.


append(CharSequence s, int start, int end)It appends a subsequence of the specified CharSequence to this sequence. 


capacity()It returns the current capacity.


charAt()It returns the char value at the specified index. An index ranges from zero to length() - 1.


codePointAt()It returns the character (Unicode code point) at the specified index. 


codePointBefore()It returns the character (Unicode code point) before the specified index. 


codePointCount()It returns the number of Unicode code points in the specified text range of this sequence. 


compareTo() It compares two StringBuffer instances lexicographically.


delete()It removes the characters in a substring of this sequence.


deleteCharAt()It removes the char at the specified position in this sequence.


ensureCapacity()It ensures that the capacity is at least equal to the specified minimum.


equals()It indicates whether some other object is "equal to" this one.


getChars()Characters are copied from this sequence into the destination character array dst. The first character to be copied is at index srcBegin; the last character to be copied is at index srcEnd-1.


indexOf()It returns the index within this string of the first occurrence of the specified substring.


Some more Methods of StringBuffer


No comments:

Post a Comment