The trick to perform this operation is by using String Functions.

The String Function <String1>.concatenate(<String2>) will concatenate both the strings together.


/* Program to enter two strings and concatenate them as one using String Function*/
import java.util.*;
class FuncConcat
public static void main()
Scanner inp=new Scanner(;

System.out.print("\n Enter First String: ");
String s1=inp.nextLine();
System.out.print("\n Enter Second String: ");
String s2=inp.nextLine();

String z=s1.concat(s2);
System.out.println("Concatenated String: "+z);



Enter First String: Sacred*

 Enter Second String: Games
Concatenated String: Sacred*Games

Report Error/ Suggestion

Related Posts:

CopyRight © 2020

CopyRight © 2020