Groovy – reverse()

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

Create a new list that is the reverse the elements of the original List.

Syntax

List reverse()

Parameters

None

Return Value

The reversed list.

Example

Following is an example of the usage of this method −

class Example { 
   static void main(String[] args) { 
      def lst = [11, 12, 13, 14]; 

      def revlst = lst.reverse(); 
      println(revlst); 
   } 
}

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

[14, 13, 12, 11] 

Previous Page:-Click Here

Leave a Reply