VOOZH about

URL: https://www.geeksforgeeks.org/java/collections-reverse-method-in-java-with-examples/

⇱ Collections.reverse() Method in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Collections.reverse() Method in Java with Examples

Last Updated : 14 Apr, 2026

The Collections.reverse() method in Java is used to reverse the order of elements in a List. It is part of the java.util.Collections class and modifies the original list directly.

  • Reverses the order of elements in a given List.
  • Works in-place, meaning it updates the original list instead of creating a new one.
  • Commonly used for changing display or processing order of data.

Example: Reversing an ArrayList


Output
Original List : [practice, code, quiz, geeksforgeeks]
Modified List: [geeksforgeeks, quiz, code, practice]

Syntax

Collections.reverse(List<?> list)

How it Works

  • It takes a List as input.
  • Reverses the order of elements inside the same list.
  • Does not return a new list; it updates the existing one.

Example: Reversing a LinkedList


Output
Original List : [practice, code, quiz, geeksforgeeks]
Modified List: [geeksforgeeks, quiz, code, practice]

If we peek through the above programs then there is only a minute signature detail that we are just creating an object of LinkedList class instead of Array class as seen in example1A. For LinkedList, we just did change as shown below in the above codes:

In the LinkedList example, we simply replace ArrayList with LinkedList while keeping the List interface reference the same.

Example: Reversing an array: Arrays class in Java doesn't have a reverse method. We can use Collections.reverse() to reverse an array also as shown below as follows:


Output
Original Array : [10, 20, 30, 40, 50]
Modified Array : [50, 40, 30, 20, 10]
  • Time Complexity: O(n), where n is the number of elements in the list, as each element is swapped once.
  • Auxiliary Space: O(1)
Comment