Menu Close

Concatenate Strings in Java …fcukthecode.com

Write a java program to print concatenated strings . You can + operator to concatenate strings and print it.

Input:     // two inputs
Enter the strings:
I am
Fine

Output:
I am Fine
import java.io.*;
import java.util.Scanner;
public class temp{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String a,b;
    System.out.println("Enter the Strings:  ");
    a = scan.nextLine();
    b = scan.nextLine();
    System.out.println(a+" "+b);
	}
}

INPUT_1:
Enter the Strings:
I am
Fine

OUTPUT:
I am Fine


INPUT_2:
Enter the Strings:
fcuk
the code

OUTPUT:
fcuk the code


INPUT_3:
Enter the Strings:
I am
almighty Overlord

OUTPUT:
I am almighty Overlord


INPUT_4:
Enter the Strings:
Hello
World

OUTPUT:
Hello World


INPUT_5:
Enter the Strings:
Hello
Metaverse, its the new Hello World Program nowadays!!!

OUTPUT:
Hello Metaverse, its the new Hello World Program nowadays!!!


ILLUSTRATION

Executed using javac in linux Terminal