Here is the Program for
concatenation
of two String
Explanation of Program
In this example we have taken a String variable 'msg' in which we've assigned the value "My name is" after assigning the value we have concatenated with other String ' Sam' using + Operator.
public class Ruler {
public static void main(String[] args) {
String msg = "My Name is";
String msg = msg + " Sam";
System.out.println(msg);
}
}
/*************************
* OUTPUT of Program
*
* My Name is Sam
************************/
Explanation of Program
In this example we have taken a String variable 'msg' in which we've assigned the value "My name is" after assigning the value we have concatenated with other String ' Sam' using + Operator.