Adds the specified string at the end.
StringBuilder sb = new StringBuilder("Hello");
sb.append(" World");
System.out.println(sb); // Hello World
Inserts the string at the specified index.
sb.insert(6, "Java "); System.out.println(sb); // Hello Java World
Replaces characters from start to end with the given string.
sb.replace(6, 10, "C++"); System.out.println(sb); // Hello C++ World
Deletes characters from start to end.
sb.delete(6, 9); System.out.println(sb); // Hello World
Reverses the content.
sb.reverse(); System.out.println(sb); // dlroW olleH
Returns the current capacity of the buffer.
System.out.println(sb.capacity()); // e.g., 27
Returns the character at the specified index.
System.out.println(sb.charAt(0)); // d
Sets the character at the index.
sb.setCharAt(0, 'D'); System.out.println(sb); // DlroW olleH
Returns substring from start to end.
System.out.println(sb.substring(0, 5)); // DlroW