String concat(String str)
描述 (Description)
此方法将一个String附加到另一个String的末尾。 该方法返回一个String,其String值传递给方法,附加到String的末尾,用于调用此方法。
语法 (Syntax)
以下是此方法的语法 -
public String concat(String s)
参数 (Parameters)
这是参数的细节 -
s - 连接到此String末尾的String。
回报价值
此方法返回一个字符串,该字符串表示此对象的字符串联,后跟字符串参数的字符。
例子 (Example)
public class Test {
public static void main(String args[]) {
String s = "Strings are immutable";
s = s.concat(" all the time");
System.out.println(s);
}
}
这将产生以下结果 -
输出 (Output)
Strings are immutable all the time