Built in packages & String buffer class

Posted on
  1. void ensureCapacity(int capacity); To pre-allocate room for a certain no. of characters after a stringBuffer has been constructed, you can use ensure capacity to set the size of the buffer.
  2. void setLength(int length); Sets the length of the buffer after the StringBuffer object has been constructed.
  3. char charAt(int where); Returns the character at a specified position.
  4. void setCharAt(int where, char ch); It will set the given character at a given position.
  5. void getChars(int sourcesstart, int sourceend, char target[], int targetstart); Constructors a character array from a stringbuffer object.
  6. StringBuffer reverse(); Reverse the characters with in a StringBuffer object.
  7. StringBuffer delete( int startindex, int endindex); It will delete the starting position to the ending position.
  8. StringBuffer deleteCharAt(int location); It will delete a character at a perticular location.
  9. StringBuffer replace(int startindex, int endindex, String str); Replaces one set of characters with another set inside StringBuffer object.

Leave a Reply

Your email address will not be published. Required fields are marked *