String and StringBuilder

String is a class of immutable strings: every modification produces a new string. Compare with equals, not ==. StringBuilder builds a string through successive modifications (append) without creating an object at each step, which is useful in loops.

Example

StringBuilder sb = new StringBuilder();
sb.append("a").append("b");
String s = sb.toString();

Related concepts

The whole glossary