10.6. The StringBuffer Class
In contrast to the String class, which implements immutable character strings, the StringBuffer class implements mutable character strings. Not only can the character string in a string buffer be changed, but the capacity of the string buffer can also change dynamically. The capacity of a string buffer is the maximum number of characters that a string buffer can accommodate before its size is automatically augmented.
Although there is a close relationship between objects of the String and StringBuffer classes, these are two independent final classes, both directly extending the Object class. Hence, String references cannot be stored (or cast) to StringBuffer references and vice versa. Both String and StringBuffer ...
Get Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition 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.