如何使用 Java 連線兩個字串?


可以使用 concat() 方法連線兩個字串。

示例

線上演示

public class ConcatinatedStrings {
   public static void main(String args[]) {
     
      String str1 = new String("Tutorials");
      String str2 = new String( "Point");
      String res = str1.concat(str2);
      System.out.println(res);
   }
}

輸出

TutorialsPoint

更新於:2020-02-19

264 次瀏覽

開啟您的 職業生涯

完成課程,獲得認證

開始學習
廣告
© . All rights reserved.