4.2. Mutable strings: StringBuilder
[9.1] Manipulate data using the StringBuilder class and its methods
The class StringBuilder is defined in the package java.lang, and it has a mutable sequence of characters. You should use the class StringBuilder when you’re dealing with larger strings or modifying the contents of a string often. Doing so will improve the performance of your code. Unlike StringBuilder, the String class has an immutable sequence of characters. Every time you modify a string that’s represented by the String class, your code creates new String objects instead of modifying the existing one.
Exam Tip
You can expect questions on the need for the StringBuilder class and its comparison with the String ...
Get OCA Java SE 8 Programmer I Certification Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.