使用 concat() 方法連線字串。


可以使用 String 類的 concat() 方法連線兩個字串。此類會將指定字串附加到此字串的末尾。

示例

即時演示

public class Test {
   public static void main(String args[]){
      String str1 = "Krishna";
      String str2 = "Kasyap";
      System.out.println(str1.concat(str2));
   }
}

輸出

krishnaKasyap

更新於: 26-Feb-2020

164 次瀏覽

開啟你的 職業生涯

完成課程獲得認證

立即開始
廣告
© . All rights reserved.