Java array reverse
import java.util.Arrays; public class Main { public static void main(String[] args) { int[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; System.out.println(Arrays.toString(array)); int arrayLength = array.length; for (int i = 0; i < arrayLength - 1; i++) { int temp = array[i]; array[i] = array[arrayLength - 1 - i]; array[arrayLength - 1 - i] = temp; }/*from w ww . j a v a 2s. co m*/ System.out.println(Arrays.toString(array)); } }