concat()String类的方法将一个String追加到另一个的末尾。该方法返回一个String,并将传递给该方法的String的值附加到String的末尾,用于调用此方法。
public class Test {
public static void main(String args[]) {
String s = "Strings are immutable";
s = s.concat(" all the time");
System.out.println(s);
}
}输出结果
Strings are immutable all the time