/* This shows how to pass arrays to methods This program is functionally equivalent to arraymanip */ public class arrayfunc { public static void main(String[] args) { // Just fill an array with some numbers int[] dataset = {1,2,3,4,5,6,7,8,9}; int[] backwards; // Print out the array for(int i=0; i<9; i++) { System.out.print(dataset[i]+" "); } System.out.println(""); // call the reverse() function to reverse the order of the array backwards = reverse(dataset); // Print out the array for(int i=0; i<9; i++) { System.out.print(backwards[i]+" "); } System.out.println(""); } // This function reverses the order of numbers stored in the array public static int[] reverse(int[] origData) { // create the new array to hold the backwards data int[] newData = new int[9]; // We are going to use this loop to reverse the order of the data for(int i=0; i<9; i++) { newData[i] = origData[(8-i)]; // load the reverse ordered values } // return the new array return(newData); } }