How do I concatenate two strings in Java?

The concatenation operator in java is +, not .

Read this (including all subsections) before you start. Try to stop thinking the php way 😉

To broaden your view on using strings in Java – the + operator for strings is actually transformed (by the compiler) into something similar to:

new StringBuilder().append("firstString").append("secondString").toString()

Leave a Comment