Sobes.tech
Junior

What methods does the StringBuilder class have?

sobes.tech AI

Answer from AI

  • append(value): Appends the string representation of the argument to the current sequence of characters.
  • insert(offset, value): Inserts the string representation of the argument at the specified position.
  • delete(start, end): Deletes the substring of characters from the specified range.
  • deleteCharAt(index): Deletes the character at the specified position.
  • replace(start, end, str): Replaces the characters in the specified range with the specified string.
  • reverse(): Reverses the sequence of characters.
  • length(): Returns the current length of the sequence of characters.
  • capacity(): Returns the current capacity of the buffer.
  • charAt(index): Returns the character at the specified position.
  • substring(start): Returns a new string containing the subsequence of characters starting from the specified index.
  • substring(start, end): Returns a new string containing the subsequence of characters from the specified range.
  • toString(): Returns the string representation of the sequence of characters.
  • ensureCapacity(minimumCapacity): Ensures that the buffer has at least the specified capacity.
  • trimToSize(): Reduces the capacity of the buffer to the actual size of the used characters.
  • indexOf(str): Returns the index of the first occurrence of the specified substring.
  • indexOf(str, fromIndex): Returns the index of the first occurrence of the specified substring, starting from the specified index.
  • lastIndexOf(str): Returns the index of the last occurrence of the specified substring.
  • lastIndexOf(str, fromIndex): Returns the index of the last occurrence of the specified substring, starting from the specified index.