Reverse Integer Array in Java
In this example, We will show simple example about, How to reverse integer array in java. The example has been tested and shared in the same post.
Example Program
package com.dineshkrish; /** * * @author Dinesh Krishnan * */ public class ArrayReverse { public static void main(String[] args) { // Your Array int[] array = { 10, 20, 30, 40, 50, 60 }; // getting the length of the array int len = array.length; // iterating the array for (int i = 0; i < len / 2; i++) { // swapping int temp = array[i]; array[i] = array[len - 1 - i]; array[len - 1 - i] = temp; } // printing the result for (int a : array) { System.out.print(a + " "); } } }
Output
—-
Your Input:
{10, 20, 30, 40, 50, 60, 70, 80, 90, 100}
Your Output:
{100, 90, 80, 70, 60, 50, 40, 30, 20, 10}
More from my site

Hello, folks, I am a founder of idineshkrishnan.com. I love open source technologies, If you find my tutorials are useful, please consider making donations to these charities.
No responses yet