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