21 September 2020

Forgotten Topic: String Buffer

This avoids polluting the string pool when accumulating strings in a loop.

Usage: To create an empty string buffer do this.

StringBuffer sb = new StringBuffer();

To get its contents as a string do this.

sb.toString();

To add stuff to a string buffer do this. There are also insert methods.

sb.append("stuff");
sb.append(42);

A StringBuffer is basically a mutable string.

`