Java Program to Concatenate two Strings

Get two strings and join them as a single string.

Sample Input 1:

MARK MAKE

Sample Output 1:

MARKMAKE

Try your Solution

Strongly recommended to Solve it on your own, Don't directly go to the solution given below.

public class Hello { public static void main(String args[]) { //Write your code here } }

Program or Solution

				
			
					
//Concate Two Given Strings...

import java.util.*;

class Program
{
  public static void main(String args[])
 {
      String str1,str2,str3;
     Scanner sc=new Scanner(System.in);

    System.out.println("Enter The String 1:");
    str1=sc.next();

   System.out.println("Enter The String 2:");
   str2=sc.next();

   str3=str1.concat(str2);

   System.out.println("The Output Is:"+str3);

 }
}


			
				
			

Program Explanation

Comments