Java String concat() Method


The String concat() method is used to concatenates str2 at the end of string str1.

Syntax:

 public String concat(String anotherString) 

Example:

 public class Concatmethod{  
    public static void main(String args[]){  
        String s1="Welcome"; 
        String s2=s1.concat(" to Onlinetpoint"); // string concate method
        String s3=s1+" to Onlinetpoint";// concate using + operator
        System.out.println(s2);  
        System.out.println(s3);
    }
}



Onlinetpoint is optimized for basic learning, practice and more. Examples are well checked and working examples available on this website but we can't give assurity for 100% correctness of all the content. This site under copyright content belongs to Onlinetpoint. You agree to have read and accepted our terms of use, cookie and privacy policy.