In this example we will show you how to add a variable to another variable in Java.
Source Code
package com.beginner.examples;
public class AddVariable {
public static void main(String[] args) {
String str1 = "abc";
String str2 = "def";
String str = str1 + str2; // add a variable to another variable
System.out.println(str);
}
}
Output:
abcdef