How to concatenate two Strings in Java?

To concatenate two Strings in Java, do this: string1 + string2.

Here's how you do it:

String hello = "Hello";
String world = "World";

String helloWorld = hello + " " + world + "!";

// Hello World!
System.out.println(helloWorld);