The trick to perform this operation without using String Functions is to use the ‘ + ‘ operator.
As in the tutorial, if + operator is used with integers, it will perform addition but when used with strings, it performs concatenation.


/* Program to enter two strings and concatenate them as one*/
import java.util.*;
class StringConcat
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+s2;
System.out.println("Concatenated String: "+z);



Enter First String: Tita

 Enter Second String: Nic
Concatenated String: TitaNic

Report Error/ Suggestion

Related Posts:

CopyRight © 2020

CopyRight © 2020