Java 程式連線字串。


字串類的 concat() 方法將指定的字串連線到此字串的末尾。

示例

即時演示

import java.lang.*;
   public class StringDemo {
      public static void main(String[] args) {

      // print str1
      String str1 = "self";
      System.out.println(str1);

      // print str2 concatenated with str1
      String str2 = str1.concat(" learning");
      System.out.println(str2);

      // prints str3 concatenated with str2(and str1)
      String str3 = str2.concat(" center");
      System.out.println(str3);
   }
}

輸出

self
self learning
self learning center

更新日期:26-2-2020

300 次瀏覽

開啟你的 職業生涯

完成課程即可獲得認證

開始
廣告
© . All rights reserved.