String Concat :
Concat() method present in the String class and it is used to combine the two String.

Example: String str1 = Hello ;
String str2 =;

In the above statements str1.concat(str2) method concatenates Hello  and into a single string 

The same concatenation can be done by using + operator, which is called string concatenation operator.
String s3=str1+str2;
String concat programing
class Test 
public static void main(String[] args) 
String age="22"; 
String s="he is "+age+" years old."; 
String str1="freetmielearn"; 
String str2="hi"; 
String str3=str1.concat(str2); 
int a=22;
String s1="he is "+a+" years old."; 
String s2="six "+2+2+2; 
String s3="six "+(2+2+2); 
Output :
he is22years old,freetmielearnhi,six222,six6

We see you’re using an ad blocker.

Our website is made possible by displaying ads to our visitors.

Please help us continue to provide you with free. So please disabling your ad blocker.