Groovy – concat()

  • Post author:
  • Post category:Groovy
  • Post comments:0 Comments
Concatenates

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

Previous Page:-Click Here

Leave a Reply