replace method

StringBuilder replace(
  1. int start,
  2. int end,
  3. String str
)

Replaces characters in the specified range with the given string.

start the starting index (inclusive) end the ending index (exclusive) str the replacement string Returns this StringBuilder for method chaining

Implementation

StringBuilder replace(int start, int end, String str) {
  delete(start, end);
  insert(start, str);
  return this;
}