reverse()
Java Collections reverse() Method
Last Updated : 17 Mar 2025
The reverse() method of Java Collections class is used to reverse the order of the elements in the specified list.
Syntax
Following is the declaration of reverse() method:
Parameter
| Parameter | Description | Required/Optional |
|---|---|---|
| list | It is the list whose elements are to be reversed. | Required |
Returns
The reverse() method does not return anything.
Exceptions
NA
Compatibility Version
Java 1.2 and above
Example 1
Output:
Original List:- [Java, PHP, Python, COBOL] Modified List:- [COBOL, Python, PHP, Java]
Example 2
Output:
Original List:- [1, 2, 3, 4] Modified List:- [4, 3, 2, 1]
Example 3
Output:
Original Array : [10, -20, 30, -40, 50] Modified Array : [50, -40, 30, -20, 10]
Next TopicJava Collections Class