/* This shows how to manipulate data in an array */ public class arraymanip { public static void main(String[] args) { // Just fill an array with some numbers int[] dataset = {1,2,3,4,5,6,7,8,9}; // Print out the array for(int i=0; i<9; i++) { System.out.print(dataset[i]+" "); } System.out.println(""); // We are going to use this loop to reverse the order of the data for(int i=0; i<5; i++) { int temp; // in order to manipulate two parts of the array at once // a temp variable will be needed temp = dataset[i]; // stores the value so it isn't overwritten dataset[i] = dataset[(8-i)]; // overwrites the value dataset[(8-i)] = temp; // value wasn't lost } // Print out the array for(int i=0; i<9; i++) { System.out.print(dataset[i]+" "); } System.out.println(""); } }