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 +.
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
Free Spring Boot Tutorial - 5 Hours Full Course
Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course