If you want to keep the StringBuilder
, you use its fluent interface
like this to remove some clutter.
builder.append("first")
.append("second")
.toString();
BTW, there is also some support in Java for pluralization and so on, but I have to admit I have never used it because in most cases it is really simpler to use a simple if. But if you want the perfect, maybe a bit overengineered solution for internationalization, you can have a look at ChoiceFormat