Concatenate strings in Java
-
-
Use the + operator
public class ConcatStrings {
public static void main(String[] args) {
String h = "Hello";
String w = "World";
String full = h + " " + w;
System.out.println(full); // Hello World
}
}
$ javac ConcatStrings.java
$ java ConcatStrings