Groovy – Concatenation of Strings

  • Post author:
  • Post category:Groovy
  • Post comments:2 Comments
concatenation of strings

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

Previous Page:-Click Here

This Post Has 2 Comments

Leave a Reply