Java examples for Collection Framework:Array Element
Reverses the order of the given array.
public class Main { /**/*from w ww. j a v a 2 s . co m*/ * Reverses the order of the given array. * * @param array * the array to reverse */ public static <E> void reverseArray(E[] array) { int i = 0; int j = array.length - 1; E tmp; while (j > i) { tmp = array[j]; array[j] = array[i]; array[i] = tmp; j--; i++; } } }