reverse()
is a function in Groovy that creates a new list that is the reverse of the elements of the original list.
List reverse()
The function takes in no parameter.
The function returns the reversed list.
class Main {static void main(String[] args) {def list = [1, 2, 3, 4]def reverselist = list.reverse()println(reverselist)}}
[4, 3, 2, 1]