Groovy - concat()



Concatenates the specified String to the end of this String.

Syntax

String concat(String str)

Parameters

str - the String that is concatenated to the end of this String.

Return Value

This methods returns a string that represents the concatenation of this object's characters followed by the string argument's characters.

Example

Following is an example of the usage of this method −

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

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

Hello World
groovy_strings.htm
Advertisements