Java 中串联字符串的最佳方法。
Java 中串联字符串的最佳方法是 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
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP