Conclusion

In this article, we saw that various methods of concatenating strings vary in performance. In most cases, the gains are negligible. Furthermore, the + operator gives by far the most readable code.

The only case when you should use a StringBuffer or StringBuilder instead of a String is when you append multiple times to one string. In this case, the StringBuffer class considerably reduces the amount of characters copied in memory.

Read more: