Groovy - Concatenation of Strings


Advertisements

Syntax

The concatenation of strings can be done by the simple ‘+’ operator.

String+String

Parameters − The parameters will be 2 strings as the left and right operand for the + operator.

Return Value − The return value is a string

Example

Following is an example of the string concatenation in Groovy.

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

When we run the above program, we will get the following result −

HelloWorld
HelloWorld
groovy_strings.htm
Advertisements