Array Mystery
Category: Array Simulation
Author: Benson Limketkai
Book Chapter: 7.2
Problem: Array Mystery
Consider the following method: public static void mystery(int[] array) { for (int i = 0; i < array.length; i++) { array[i] = array[array.length - 1 - i]; array[array.length - 1 - i] = array[i]; } } Indicate in the right-hand column what values would be stored in the array after the method mystery executes if the integer array in the left-hand column is passed as a parameter to mystery. int[] a1 = {8}; int[] a2 = {14, 7}; int[] a3 = {7, 1, 3, 2, 0, 4}; int[] a4 = {10, 8, 9, 5, 6}; int[] a5 = {8, 10, 8, 6, 4, 2};
1) mystery(a1);
2) mystery(a2);
3) mystery(a3);
4) mystery(a4);
5) mystery(a5);