Groovy - Strings reverse()


Advertisements

Creates a new String which is the reverse of this String.

Syntax

String reverse()

Parameters

None

Return Value

This method returns the resulting String.

Following is an example of the usage of this method −

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

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

dlroW olleH
groovy_strings.htm
Advertisements