Q:

Java program to concatenate two strings

0

Java program to concatenate two strings

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program to concatenate two strings in java

import java.util.Scanner;

public class StringConcatenation 
{
	public static void main(String args[])
	{   // creating object of the string s1,s2.
		String s1,s2;
		Scanner sc=new Scanner(System.in);
		// enter both the string one by one.
		System.out.print("Enter First String : ");
		s1=sc.nextLine();
		 
		System.out.print("Enter Second String : ");
		s2=sc.nextLine();
		
		// here we print the whole string after concatenation.
		System.out.println("String After Concatenation : " +s1.concat(s2));
	}
}

Output

First run:
Enter First String : Include
Enter Second String : Help
String After Concatenation :IncludeHelp

Second run:
Enter First String : Java
Enter Second String : Programming
String After Concatenation : JavaProgramming

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now