Java String concat() method Example

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


method signature


public String concat(String str)


Example


package com.practice;

public class StringconcatDemo {
public static void main(String[] args) {
String string1 = "Welcome";
String string2 = string1.concat("to Home");
System.out.println(string2);

}

}

output


Welcometo Home

No comments:

Post a Comment

-->