Groovy - concat()



將指定字串合併到此字串的末尾。

語法

String concat(String str)

引數

str - 合併到此字串末尾的字串。

返回值

此方法返回一個表示此物件字元和字串引數字元相繼連線的字串。

示例

以下是此方法使用方法的一個示例 −

class Example {
   static void main(String[] args) {
      String s = "Hello ";
      s = s.concat("World");
      System.out.println(s);
   } 
}

當我們執行以上程式時,將獲得以下結果 −

Hello World
groovy_strings.htm
廣告
© . All rights reserved.