class Reverse { /* * This program demonstrates how to reverse the content of an array * in-place using a constant amount of temporary memory. */ public static void main(String[] args) { int [] a = { 2, 3, 1, 8, 4, 5, 8 }; for (int i = 0; i < a.length; i++) System.out.print(a[i] + " "); System.out.println(); for (int i = 0, j = a.length-i-1; i < j; i++, j--) { int t = a[i]; a[i] = a[j]; a[j] = t; } for (int k = 0; k < a.length; k++) System.out.print(a[k] + " "); System.out.println(); } }