In this example we will show the method to combine text and a variable in Java.
Source Code
package com.beginner.examples;
public class CombineText {
public static void main(String[] args) {
String str = "Hello ";
System.out.println(str + "World"); // combine text and a variable
}
}
Output:
Hello World