Using the StringBuffer Class
The StringBuffer class enables you to create String objects that can be changed in various ways, unlike the String class, which are immutable. When you modify a string of the StringBuffer class, you're not creating a new String object, but rather operating directly on the original string itself. For this reason, the StringBuffer class offers a different set of methods than the String class, all of which operate directly on the buffer that contains the string.
Creating a StringBuffer Object
The StringBuffer class offers several constructors that enable you to construct a StringBuffer object in various ways. Those constructors look like this:
StringBuffer() StringBuffer(int length) StringBuffer(String str)
These constructors ...
Get Special Edition Using Java 2 Standard 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.