Figure 4.18. Comparing the replace methods in String (left) and StringBuilder (right). The method replace in String accepts the characters to be replaced. The method replace in StringBuilder accepts a position to be replaced.
Apart from using the method substring, you can also use the method subSequence to retrieve a subsequence of a StringBuilder object. This method returns objects of type CharSequence:
The method subsequence doesn’t modify the existing value of a StringBuilder object.
4.2.4. A quick note on the class StringBuffer ...