Java Programming Example of concatenation of two strings.

This program accepts the two strings from the keyboard and concatenate the two strings and stores into a new string.

import java.io.*;

/**
 *
 * @author JavaHotSpot
 */

public class stringConcat
{
 public static void main(String args[])
 {

     String s1,s2,s3;
     DataInputStream d;
     try
     {
     System.out.println("Enter the First String");
     d=new DataInputStream(System.in);
     s1=(String)d.readLine();
     System.out.println("Enter the Second String");
     s2=(String)d.readLine();
     s3=s1.concat(s2);
     System.out.println("The new String is = "+s3);

     }
     catch(Exception e)
     {
         System.out.println(e.toString());
     }
 }
}

Output:
Enter the First String
Java
Enter the Second String
HotSpot