arrays have no concept of negative indices, if you want to traverse from the last to first then you must START at the LAST index and move to the FIRST.

for(i =3; i>0; i--){

   System.out.println(var[i - 1]);

}
Answer from T McKeown on Stack Overflow
๐ŸŒ
Quora
quora.com โ€บ How-do-I-Print-reverse-of-an-array-in-java
How to Print reverse of an array in java - Quora
Answer (1 of 8): Well, what you have appears to be correct. What is it that bothers you about the code? Does it seem too simple? Well, doesnโ€™t it do precisely what you said you wanted to do? There are other ways to do it, but they would be more complicated.
๐ŸŒ
Software Testing Help
softwaretestinghelp.com โ€บ home โ€บ java โ€บ how to reverse an array in java: 3 methods with examples
How to Reverse An Array In Java: 3 Methods With Examples
March 24, 2020 - In this guide, youโ€™ll be learning three simple methods on how to reverse an array in Java, along with examples, in a way that is easy to understand. => Check Out The Ultimate Java Training Series Here ... Alternatively, if we want to print the array in the reverse order, without actually reversing it, then we can do that just by providing a for loop that will start printing from the end of the array.
๐ŸŒ
Quescol
quescol.com โ€บ home โ€บ java program to print array in reverse order
Java Program to Print Array in Reverse Order - Quescol
May 8, 2025 - The input array size is 5, so the โ€˜for loopโ€™ will executes the body 5 times taking input from the users as the elements of the array, which is {4,3,2,1,3}. The program returned the reverse of the input array i.e. {3,1,2,3,4}. import java.util.*; public class Main { public static void main(String[] args) { int startIndex,lastIndex; Scanner sc = new Scanner(System.in); System.out.print("Enter the size of array: "); int size = sc.nextInt(); int arr[] = new int[size]; int reverse[] = new int[size]; for(int i=0; i<size; i++) { System.out.print("Please give value for index "+ i +" : "); arr[i] = sc.nextInt(); } startIndex = 0; lastIndex = size - 1; while(lastIndex >= 0) { reverse[startIndex] = arr[lastIndex]; startIndex++; lastIndex--; } System.out.println("Array After Reversing :"); for(int i=0; i<size; i++) { System.out.print(reverse[i]); } } }
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ reverse an array in java
Reverse an Array in Java - Scaler Topics
April 28, 2024 - In the above program, we are accessing the elements of the array in reverse order along with simultaneously printing them on the screen.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ java-iterate-array-in-reverse-order
Java - Iterate Array in Reverse Order - GeeksforGeeks
July 23, 2025 - // Java Program to iterate over ... 40, 50}; // Reversing the array Collections.reverse(Arrays.asList(arr)); // Iterating over the reversed array for (int n : arr) { System.out.print(n + " "); } } }...
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ reverse-an-array-in-java
Reverse an Array in Java - GeeksforGeeks
July 11, 2025 - // Java Program to reverse an array // using loop import java.util.Arrays; public class Geeks { public static void main(String[] args) { int[] arr = {1, 2, 3, 4, 5}; // Swap elements from start to end for (int i = 0; i < arr.length / 2; i++) { int t = arr[i]; arr[i] = arr[arr.length - 1 - i]; arr[arr.length - 1 - i] = t; } System.out.println("" + Arrays.toString(arr)); } }
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 50918843 โ€บ printing-elements-of-array-called-top10-backwards
java - Printing elements of array called top10 backwards - Stack Overflow
Using the int[] element: myarray gives me all the items in the array, and the break stops the printing loop when you reach the 10th, if you don't, it still stops when you run out of items (like with just 9) If your array is multi-dimensional you can just nest the for-loops to iterate the inner levels, or use the Arrays.toString(myarray) function from java.util.Arrays;
๐ŸŒ
CodeGym
codegym.cc โ€บ java blog โ€บ java arrays โ€บ reverse an array in java
Reverse an Array in Java
January 16, 2025 - As a result the reverse order of ... reverse : [25, 16, 9, 4, 1] In Java, the reverse method, which is part of the existing Collections framework, can be used to reverse an array....
๐ŸŒ
Techcrashcourse
techcrashcourse.com โ€บ 2018 โ€บ 12 โ€บ java-program-to-reverse-array-elements-using-loop.html
Java Program to Reverse Array Elements
Declare another array of size N, let it be "reverseArray". Using a for loop, copy elements from inputArray to reverseArray in reverse order. For example, copy last element of inputArray to first position of reverseArray and so on. Now, using a for loop, traverse reverseArray from index 0 to ...
๐ŸŒ
LearnYard
read.learnyard.com โ€บ dsa โ€บ print-array-in-reverse-order
Print Array in Reverse Order Solution in C++/Java/Python/JS
May 11, 2025 - // Function to print each element of the array in reverse order function printArrayInReverse(nums, size) { for (let index = size - 1; index >= 0; --index) { process.stdout.write(nums[index] + " "); } console.log(); // Newline for better output ...
๐ŸŒ
Medium
medium.com โ€บ @AlexanderObregon โ€บ reversing-the-order-of-an-array-with-java-loops-95b3546e023b
Reversing the Order of an Array with Java Loops | Medium
September 7, 2025 - Learn how to reverse arrays in Java by looping from the end back to the start. Covers memory layout, index control, printing, storing, and swapping values.
๐ŸŒ
Tpoint Tech
tpointtech.com โ€บ java-program-to-print-the-elements-of-an-array-in-reverse-order
Java Program to print the elements of an array in reverse order - Tpoint Tech
September 1, 2025 - In this section, we are going to solve another popular coding problem that was asked by e-commerce companies Flipkart and Amazon. Also, we will solve the problem with different approaches and create Java programs.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ dsa โ€บ program-to-reverse-an-array
Array Reverse - GeeksforGeeks
#include <stdio.h> #include <stdlib.h> void reverseArray(int arr[], int n) { // Temporary array to store elements // in reversed order int temp[n]; // Copy elements from original array // to temp in reverse order for(int i = 0; i < n; i++) temp[i] = arr[n - i - 1]; // Copy elements back to original array for(int i = 0; i < n; i++) arr[i] = temp[i]; } int main() { int arr[] = { 1, 4, 3, 2, 6, 5 }; int n = sizeof(arr) / sizeof(arr[0]); reverseArray(arr, n); for(int i = 0; i < n; i++) printf("%d ", arr[i]); return 0; } ... import java.util.Arrays; class GfG { static void reverseArray(int[] arr) {
Published ย  2 days ago
Top answer
1 of 1
1

What's most efficient and what is better are usually not the same thing.

The first question you should ask in this situation is how you ended up needing to traverse your data structure in reverse in the first place. Why can't it be built in the correct order at the start?

It's far easier to fix bad code than it is to work with bad data structures. Don't accept this situation if you don't have to.

If you have to, the next question is do you really want to couple the reversing code with the printing code? The second approach makes much more sense when you decouple them.

List<Integer> listInteger = Arrays.asList(array);
Collections.reverse(listInteger);
media.display(listInteger);

display may send it to system out, or load it up in a gui, or print it on paper, or turn it into part of a web page, or ...

The first approach works when you just want a hard coded quick and dirty way to get it on the screen.

As for which is more 'efficient' the first one reuses existing memory while the second makes a copy. If the array is huge enough for that to matter then fine. But why the hell did you create it backwards in first place?

The first makes the computer happy and leaves me mourning the loss of flexibility. The choice of who to make happy is up to you.

Keep in mind, premature flexibility (see BDUF vs YAGNI) is almost as bad as premature optimization. So whatever you do, realize you've already spent too much time thinking about this.

Also, it turns out there is a better way to implement the second option. It's detailed here.