Use the .clone() method on your List. It will return a shallow copy, meaning that it will contain pointers to the same objects, so you won't have to copy the list. Then just use Collections.

Ergo,

Collections.reverse(list.clone());

If you are using a List and don't have access to clone() you can use subList():

List<?> shallowCopy = list.subList(0, list.size());
Collections.reverse(shallowCopy);
Answer from jcalvert on Stack Overflow
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java list โ€บ reverse an arraylist in java
Reverse an ArrayList in Java | Baeldung
April 3, 2025 - As we can see, when the list object contains only one element (7), we stop the recursion and then start executing list.add(value) from the bottom. That is, we first add 6 to the end of the list, then 5, then 4, and so on. In the end, the order of the elements in the list has been in-place reversed.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ java-program-to-reverse-a-list
Java Program to Reverse a List - GeeksforGeeks
July 23, 2025 - ... // Java program to reverse the list // using Collections.reverse() method import java.io.*; import java.util.*; class GFG { public static void main(String[] args) { List<Integer> number = new ArrayList<>( Arrays.asList(1, 2, 3, 4, 5, 6, ...
Discussions

reversing a linkedList explanation- Java
Draw it out on paper with a small list of 4 or 5 elements. More on reddit.com
๐ŸŒ r/learnprogramming
9
November 20, 2022
[Java] Need help reversing integers of a List into a separate ArrayList.
The issue is that on line 18 you call reverse(null), which sets list to null in reverse so when you try to access anything in list it will give you a NullPointerException. More on reddit.com
๐ŸŒ r/learnprogramming
27
4
December 9, 2015
java - What is the Simplest Way to Reverse an ArrayList? - Stack Overflow
Sign up to request clarification or add additional context in comments. ... @AgarwalShankar i am getting an error required ArrayList found void. Am i missing something. 2015-01-05T06:52:06.757Z+00:00 ... Collections.reverse(List); I used it in an Android project, works fine. More on stackoverflow.com
๐ŸŒ stackoverflow.com
[JAVA] Is there a way to make this reverse method more efficient? Possibly requiring only one loop?
Why are you iterating from 0 to size and then have your calculation? You could directly iterate in the opposite direction Since you have index-based access to the list elements, you should be able to do an in-place swap via a third, temp element (single element, not a list). In this case, you only need a single loop and only need to iterate over half the list. More on reddit.com
๐ŸŒ r/learnprogramming
9
5
October 10, 2022
๐ŸŒ
FavTutor
favtutor.com โ€บ blogs โ€บ reverse-list-java
8 Ways to Reverse a List in Java | FavTutor
January 22, 2022 - In this method, we create a recursive function that removes the first element from the list and then makes a recursive call to itself. When the recursive call returns, the removed element is added again to the list.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ java-program-to-reverse-a-list
How to reverse an array list in Java
June 14, 2024 - Home Whiteboard Graphing Calculator Online Compilers Articles Tools ... Python TechnologiesDatabasesComputer ProgrammingWeb DevelopmentJava TechnologiesComputer ScienceMobile DevelopmentBig Data & AnalyticsMicrosoft TechnologiesDevOpsLatest TechnologiesMachine LearningDigital MarketingSoftware QualityManagement Tutorials View All Categories ... Following example reverses an array list by using Collections.reverse(ArrayList)method. import java.util.ArrayList; import java.util.Collections; public class Main { public static void main(String[] args) { ArrayList arrayList = new ArrayList(); arrayList.add("A"); arrayList.add("B"); arrayList.add("C"); arrayList.add("D"); arrayList.add("E"); System.out.println("Before Reverse Order: " + arrayList); Collections.reverse(arrayList); System.out.println("After Reverse Order: " + arrayList); } }
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ collections-reverse-method-in-java-with-examples
Collections.reverse() Method in Java with Examples - GeeksforGeeks
The reverse() method of the Collections class, as the name suggests, is used to reverse the order of elements in a list. Note: It does not sort the elements, it simply reverses their current order.
Published ย  July 23, 2025
๐ŸŒ
codippa
codippa.com โ€บ home โ€บ how to reverse a list in java in different ways
How to reverse a list in java in different ways - codippa
July 11, 2025 - It is a static method and thus can be invoked directly by using the class name. import java.util.List; import java.util.ArrayList; import java.util.Collections; public class ReverseListUsingCollections { public static void main(String[] args) { // create an empty list to reverse List list = new ArrayList<>(); // add elements list.add("Google"); list.add("Facebook"); list.add("Youtube"); list.add("Whatsapp"); list.add("Instagram"); System.out.println("Before reversing..."); System.out.println(list); Collections.reverse(list); System.out.println("After reversing..."); System.out.println(list); } }
Find elsewhere
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ reversing-a-list-in-java-in-place-and-out-of-place
Reversing a List in Java - In-Place and Out-Of-Place
October 10, 2022 - In this short guide, you've learned how to reverse a list in Java, in-place and out-of-place, preserving the original list from the operation.
๐ŸŒ
JavaBeat
javabeat.net โ€บ home โ€บ how to reverse a list in java?
How to Reverse a List in Java?
November 30, 2023 - The reversal of a list in Java can be done manually by the utilization of โ€œadd()โ€ and โ€œremove()โ€ methods with the โ€œforโ€ loop. The working of this approach is explained below: Step 1: The โ€œforโ€ loop iterates the list from the ...
๐ŸŒ
Reddit
reddit.com โ€บ r/learnprogramming โ€บ reversing a linkedlist explanation- java
r/learnprogramming on Reddit: reversing a linkedList explanation- Java
November 20, 2022 -

Hi all,

I am struggling to understand how you reverse a linkedList.

I have done some googling and found this:

ListNode reverseList(ListNode head) {

ListNode previous = null;

ListNode current = head;

while (current != null) {

ListNode nextElement = current.getNext();

current.setNext(previous);//line a

previous = current; //line b

current = nextElement;

}

return previous;

}

I don't understand purpose of lines a and b. Could you explain?

How is this reversing the list? Honestly, so confused that I cann't even formulate the correct question.

let me know if u can help. Thanks in advance.

I am familiar with Java so try to keep that in mind with the explanations please.

๐ŸŒ
Stack Abuse
stackabuse.com โ€บ java-8-streams-collect-and-reverse-stream-into-list
Java 8 Streams - Collect and Reverse Stream into List
December 13, 2021 - In this short guide, we've taken a look at how you can collect and reverse a stream/list in Java 8, using collect() and Collections.reverse() - individually, and together through the collectingAndThen() method.
๐ŸŒ
Blogger
javarevisited.blogspot.com โ€บ 2016 โ€บ 05 โ€บ how-to-reverse-arraylist-in-place-in-java.html
How to reverse an ArrayList in place in Java? Example [Solved]
July 11, 2025 - By the way, if you need to reverse an ArrayList then you should be using the Collections.reverse() method provided by the Java Collection framework. It's a generic method, so you can not only reverse an ArrayList but also Vector, LinkedList, CopyOnWriteArrayList, or any other List implementation.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ java โ€บ util โ€บ collections_reverse.htm
Java Collections reverse() Method
Python TechnologiesDatabasesComputer ... MarketingSoftware QualityManagement Tutorials View All Categories ... The Java Collections reverse(List<?>) method is used to reverse the order of the elements in the specified li...
๐ŸŒ
HackerEarth
hackerearth.com โ€บ practice โ€บ notes โ€บ java-iterate-over-a-list-in-the-reverse-order-example
Java: Iterate over a list in the reverse order example - Yogendra Gadilkar
July 10, 2024 - As we can see it's easy to transverse a list in the reverse order, but what about making this reusable? ... Every class that implements the Iterable interface it's declaring itself as iterable so it must provide an Iterator. This way the callers are able to iterate over elements in some data structure provided by the class. With this in mind we can write something like the following: ReversedIterator class import java.util.Iterator; import java.util.List; import java.util.ListIterator; public class ReversedIterator<T> implements Iterable<T> { private List<T> list; public ReversedIterator(List<
๐ŸŒ
Reddit
reddit.com โ€บ r/learnprogramming โ€บ [java] need help reversing integers of a list into a separate arraylist.
r/learnprogramming on Reddit: [Java] Need help reversing integers of a List into a separate ArrayList.
December 9, 2015 -

This is a review question for my upcoming intro to programming exam and I need some help fixing my code. The question explicitly states to write a method that takes a List of integers and returns a new ArrayList in reverse order. It also says that we can assume we have methods prepend and append which add a new element to the beginning/end.

Here is my current code which gives me a NullPointerException

public static ArrayList<Integer> reverse(List<Integer> list){
	ArrayList<Integer> list2 = new ArrayList<Integer>();

	list.add(5);
	list.add(10);
	list.add(15);
	list.add(20);
	
	System.out.println(list);

	for(int i = 0, j = list.size()-1; i < j; i++){
		list2.add(i, list.remove(j));
	}
	
	return list2;
}
public static void main(String[] args){
	reverse(null);
}

Any help would be greatly appreciated. Thank you.

Edit: I am getting closer, 2 of the 4 objects are being reversed and displayed. More information is in the comments below.

Edit2: Thank you so much for all the help today guys, I understand this concept a lot better after reading through everyone's comments!

๐ŸŒ
Codemia
codemia.io โ€บ knowledge-hub โ€บ path โ€บ iterating_through_a_list_in_reverse_order_in_java
Iterating through a list in reverse order in java
March 24, 2020 - Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
๐ŸŒ
w3resource
w3resource.com โ€บ java-exercises โ€บ collection โ€บ java-collection-exercise-11.php
Java - Reverse elements in an array list
April 7, 2024 - List before reversing : [Red, Green, Orange, White, Black] List after reversing : [Black, White, Orange, Green, Red] ... Write a Java program to reverse an ArrayList using Collections.reverse() and then print the reversed list.
๐ŸŒ
Linux Hint
linuxhint.com โ€บ reverse-a-list-in-java
How to Reverse a List in Java
July 23, 2025 - Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java list โ€บ iterating backward through a list
Iterating Backward Through a List | Baeldung
September 15, 2020 - An Iterator is an interface in the Java Collections Framework that allows us to iterate over the elements in a collection. It was introduced in Java 1.2 as a replacement of Enumeration. The most simple implementation is to use a for loop to start from the last element of the list, and decrement the index as we reach the beginning of the list:
Top answer
1 of 13
901
Collections.reverse(aList);

Example (Reference):

ArrayList aList = new ArrayList();
//Add elements to ArrayList object
aList.add("1");
aList.add("2");
aList.add("3");
aList.add("4");
aList.add("5");
Collections.reverse(aList);
System.out.println("After Reverse Order, ArrayList Contains : " + aList);
2 of 13
26

The trick here is defining "reverse". One can modify the list in place, create a copy in reverse order, or create a view in reversed order.

The simplest way, intuitively speaking, is Collections.reverse:

Collections.reverse(myList);

This method modifies the list in place. That is, Collections.reverse takes the list and overwrites its elements, leaving no unreversed copy behind. This is suitable for some use cases, but not for others; furthermore, it assumes the list is modifiable. If this is acceptable, we're good.


If not, one could create a copy in reverse order:

static <T> List<T> reverse(final List<T> list) {
    final List<T> result = new ArrayList<>(list);
    Collections.reverse(result);
    return result;
}

This approach works, but requires iterating over the list twice. The copy constructor (new ArrayList<>(list)) iterates over the list, and so does Collections.reverse. We can rewrite this method to iterate only once, if we're so inclined:

static <T> List<T> reverse(final List<T> list) {
    final int size = list.size();
    final int last = size - 1;

    // create a new list, with exactly enough initial capacity to hold the (reversed) list
    final List<T> result = new ArrayList<>(size);

    // iterate through the list in reverse order and append to the result
    for (int i = last; i >= 0; --i) {
        final T element = list.get(i);
        result.add(element);
    }

    // result now holds a reversed copy of the original list
    return result;
}

This is more efficient, but also more verbose.

Alternatively, we can rewrite the above to use Java 8's stream API, which some people find more concise and legible than the above:

static <T> List<T> reverse(final List<T> list) {
    final int last = list.size() - 1;
    return IntStream.rangeClosed(0, last) // a stream of all valid indexes into the list
        .map(i -> (last - i))             // reverse order
        .mapToObj(list::get)              // map each index to a list element
        .collect(Collectors.toList());    // wrap them up in a list
}

nb. that Collectors.toList() makes very few guarantees about the result list. If you want to ensure the result comes back as an ArrayList, use Collectors.toCollection(ArrayList::new) instead.


The third option is to create a view in reversed order. This is a more complicated solution, and worthy of further reading/its own question. Guava's Lists#reverse method is a viable starting point.

Choosing a "simplest" implementation is left as an exercise for the reader.