目录

两个字符串的连接(Concatenation of two strings)

Syntax

字符串的串联可以通过简单的“+”运算符完成。

String+String

Parameters - 参数将是2个字符串作为+运算符的左右操作数。

Return Value - 返回值是一个字符串

例子 (Example)

以下是Groovy中字符串连接的示例。

class Example {
   static void main(String[] args) {
      String a = "Hello";
      String b = "World";
      println("Hello" + "World");
      println(a + b);
   }
}

当我们运行上述程序时,我们将得到以下结果 -

HelloWorld
HelloWorld
↑回到顶部↑
WIKI教程 @2018