Groovy - concat()
将指定的字符串连接到此字符串的末尾。
语法
String concat(String str)
参数
str - 连接到此字符串末尾的字符串。
返回值
此方法返回一个字符串,该字符串表示此对象的字符后跟字符串参数的字符的串联。
示例
以下是该方法的用法示例 −
class Example {
static void main(String[] args) {
String s = "Hello ";
s = s.concat("World");
System.out.println(s);
}
}
当我们运行上面的程序时,会得到下面的结果 −
Hello World

