Java String concat() Method Example

Java String concat() method concatenates the specified string to the end of this string.

String concat() method creates a new object that contains the invoking string with the contents of str appended to the end. concat()  performs the same function as +.

Java String concat() Method Example

public class ConcatExmaple {
    public static void main(String[] args) {
        String str = "javaguides";
        str = str.concat(".net");
        System.out.println("Concatenates the specified string to the end of this string : " + str);
        System.out.println("cares".concat("s"));
        System.out.println("to".concat("get"));
    }
}

Output:
Concatenates the specified string to the end of this string: javaguides.net caress toget 

Comments