In addition to the charAt(), indexOf(), substring(), length() methods that work in the String object, StringBuilder has other main methods that we’ll cover in the following:
The append() method adds a value at the end of the current string of the StringBuilder object. We can add a variety of data types using overloading methods of this method.
For example:
The insert() method inserts data at any location in the StringBuilder object.
For example:
The delete() method with two start and end arguments is used to delete a string with the start and end indexes.
For example:
Note that this method will not delete the character at the end index!
The deleteCharAt() method deletes a character at any location in the string of the StringBuilder object.
For example:
The reverse() method reverses the characters in the string of the StringBuilder object.
For example:
The replace() method replaces any string from the start index to the end index in the string of the StringBuilder object.
For example:
As the delete() method, the character at the end will not be counted in the character to replace!
The subsequence() method takes a string from the start index to the end index in the string of the StringBuilder object.
Note that using the subsequence() method will not change our StringBuilder object, and the new string will not have the character at the end.
For example: