Section 14.4 Class StringBuilder

• Class StringBuilder provides constructors that enable StringBuilders to be initialized with no characters and an initial capacity of 16 characters, with no characters and an initial capacity specified in the integer argument, or with a copy of the characters of the String argument and an initial capacity that’s the number of characters in the String argument plus 16.

StringBuilder method length (p. 612) returns the number of characters currently stored in a StringBuilder. StringBuilder method capacity (p. 612) returns the number of characters that can be stored in a StringBuilder without allocating more memory.

StringBuilder method ensureCapacity (p. 613) ensures that a StringBuilder has at least the specified ...

Get Java™ How To Program (Early Objects), Tenth 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.