O'Reilly logo

OCA Java SE 7 Programmer I Certification Guide: Prepare for the 1Z0-803 exam by Mala Gupta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

SubSequence()

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required