Java Collections reverse() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
java.util.Collections

Definition

In Java, Collections.reverse(list) reverses the order of the elements in a List: the first element swaps places with the last, the second with the second-to-last, and so on. The list is changed in place and the method returns nothing.

It does not compare elements, so it is not the same as sorting in descending order. It only mirrors whatever order the list has right now. Reversing twice brings back the original order.

A static method of the java.util.Collections utility class, available since Java 1.2. Call it on the class name, as in Collections.reverse(...), after import java.util.Collections;. You never create a Collections object.

Syntax

Pass the list you want to flip.

Java
List<Integer> nums = new ArrayList<>(Arrays.asList(1, 2, 3));
Collections.reverse(nums);            // [3, 2, 1]
Collections.reverse(nums.subList(0, 2));  // only the first two: [2, 3, 1]
CallWhat it does
Collections.reverse(list)Mirrors the whole list.
Collections.reverse(list.subList(a, b))Mirrors only indexes a to b - 1.
Collections.reverse(Arrays.asList(arr))Reverses an object array through its list view.
Collections.sort(list, Collections.reverseOrder())Descending sort, which is a different job.

reverse runs in linear time. It walks from both ends toward the middle, swapping pairs, so a list with an odd number of elements keeps its middle element in place.

Library declarations
Java
// java.util.Collections
public static void reverse(List<?> list)

Parameters

ParameterDescription
listThe list whose elements are reversed. It must support set.

Return Value

Return ValueDescription
voidNothing. The list now holds its elements in the opposite order.

Compare with Similar Methods

Methods that change the order of a list:

MethodHow it differs
sort(list)Compares elements and puts them in ascending order.
reverseOrder()A comparator for a true descending sort.
rotate(list, d)Shifts every element by a distance instead of mirroring.
shuffle(list)Puts the elements in a random order.

Java Examples

Example 1 — Reverse a List and Watch the Middle

Reverse five numbers, check where the middle one ends up, then reverse again.

Java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class CollectionsReverseMirror {
    public static void main(String[] args) {
        List<Integer> nums = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5));
        System.out.println("Before: " + nums + ", 3 at index " + nums.indexOf(3));

        Collections.reverse(nums);
        System.out.println("After:  " + nums + ", 3 at index " + nums.indexOf(3));

        Collections.reverse(nums);
        System.out.println("Twice:  " + nums);
    }
}

How It Works

  1. Pairs swap. Index 0 swaps with index 4 and index 1 with index 3, so 1 and 5 trade places, then 2 and 4.
  2. Middle stays. With five elements, index 2 has no partner, so the 3 is still at index 2 after reversing.
  3. Undo. A second reverse mirrors the list back to its starting order.

Example 2 — reverse() Is Not the Same as Sorting Descending

Reversing an unsorted list only mirrors it. Sort first, then reverse, to get high-to-low order.

Java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class CollectionsReverseVsSort {
    public static void main(String[] args) {
        List<Integer> prices = new ArrayList<>(Arrays.asList(30, 10, 20));

        List<Integer> mirrored = new ArrayList<>(prices);
        Collections.reverse(mirrored);
        System.out.println("Only reversed:      " + mirrored);

        List<Integer> descending = new ArrayList<>(prices);
        Collections.sort(descending);
        Collections.reverse(descending);
        System.out.println("Sorted, reversed:   " + descending);
    }
}

How It Works

  1. Plain mirror. Reversing 30, 10, 20 gives 20, 10, 30, which is not ordered at all.
  2. Sort first. The second copy is sorted to 10, 20, 30 before it is reversed.
  3. Descending result. Mirroring an ascending list produces 30, 20, 10. Passing Collections.reverseOrder() to sort would reach the same result in one step.

Example 3 — Reverse an Array and Part of a List

Reverse a String array through its list view, and reverse just three elements in the middle of a list.

Java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class CollectionsReversePart {
    public static void main(String[] args) {
        String[] letters = {"a", "b", "c", "d", "e", "f"};
        Collections.reverse(Arrays.asList(letters));
        System.out.println(Arrays.toString(letters));

        List<Integer> nums = new ArrayList<>(Arrays.asList(10, 20, 30, 40, 50, 60));
        Collections.reverse(nums.subList(1, 4));
        System.out.println(nums);
    }
}

How It Works

  1. The array changes. Arrays.asList(letters) writes straight into letters, so after reversing the view the array itself reads f to a.
  2. A window. nums.subList(1, 4) covers indexes 1, 2, and 3: the values 20, 30, 40.
  3. Only the window flips. Those three become 40, 30, 20, while 10, 50, and 60 stay where they were.

Frequently Asked Questions

It reverses the order of the elements in a List in place. The first element becomes the last and the last becomes the first.
No. It only mirrors the current order. Sort the list first, or use Collections.sort(list, Collections.reverseOrder()).
For an object array such as String[] or Integer[], call Collections.reverse(Arrays.asList(array)). It does not work on an int[], because Arrays.asList(int[]) makes a list with one element: the whole array.
No. It returns void and changes the list you pass in. Copy the list first if you need to keep the original order.
No. It throws UnsupportedOperationException. Make a copy with new ArrayList<>(list) and reverse the copy.

Next: reverseOrder()

Get a Comparator that sorts in reverse (descending) order.

reverseOrder() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

15 people found this page helpful