StringBuffer Class Methods List


Here is a complete list of methods available in the StringBuffer class in Java:

  1. append(boolean b)
  2. append(char c)
  3. append(char[] str)
  4. append(char[] str, int offset, int len)
  5. append(double d)
  6. append(float f)
  7. append(int i)
  8. append(long lng)
  9. append(Object obj)
  10. append(String str)
  11. capacity()
  12. charAt(int index)
  13. codePointAt(int index)
  14. codePointBefore(int index)
  15. codePointCount(int beginIndex, int endIndex)
  16. delete(int start, int end)
  17. deleteCharAt(int index)
  18. ensureCapacity(int minimumCapacity)
  19. getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
  20. indexOf(String str)
  21. indexOf(String str, int fromIndex)
  22. insert(int offset, boolean b)
  23. insert(int offset, char c)
  24. insert(int offset, char[] str)
  25. insert(int offset, char[] str, int strOffset, int strLen)
  26. insert(int offset, double d)
  27. insert(int offset, float f)
  28. insert(int offset, int i)
  29. insert(int offset, long l)
  30. insert(int offset, Object obj)
  31. insert(int offset, String str)
  32. lastIndexOf(String str)
  33. lastIndexOf(String str, int fromIndex)
  34. length()
  35. offsetByCodePoints(int index, int codePointOffset)
  36. replace(int start, int end, String str)
  37. reverse()
  38. setCharAt(int index, char ch)
  39. setLength(int newLength)
  40. substring(int start)
  41. substring(int start, int end)
  42. toString()
  43. trimToSize()

These methods can be used to perform various operations on string buffers, such as appending or inserting new characters, deleting characters, finding and replacing substrings, and many others. Some methods are used to manipulate the buffer's length and capacity, while others are used to obtain information about the contents of the buffer, such as its length or the value of a particular character at a given index.