//How to add two strings in java
import java.util.*;
public class M
{
public static void main(String args[])
{
String str1,str2,str3;
System.out.println("Enter first String:");
Scanner sc=new Scanner(System.in);
str1=sc.nextLine();
System.out.println("Enter second String:");
str2=sc.nextLine();
str3=str1+str2;
System.out.println("Combination of String: "+str3);
}
}
OUTPUT:
Enter first String:
Hello
Enter second String:
World
Combination of String: HelloWorld
import java.util.*;
public class M
{
public static void main(String args[])
{
String str1,str2,str3;
System.out.println("Enter first String:");
Scanner sc=new Scanner(System.in);
str1=sc.nextLine();
System.out.println("Enter second String:");
str2=sc.nextLine();
str3=str1+str2;
System.out.println("Combination of String: "+str3);
}
}
OUTPUT:
Enter first String:
Hello
Enter second String:
World
Combination of String: HelloWorld
No comments:
Post a Comment