class ArrayChange { public static void main(String[] args) { int[] myarray = new int[10]; int[] array2; for(int i = 0; i < myarray.length; i++) myarray[i] = i+1; System.out.println("The original array:"); for(int i = 0; i < myarray.length; i++) System.out.println("myarray[" + i + "] = " + myarray[i]); changeArray(myarray); System.out.println("After the call to arrayChange()"); for(int i = 0; i < myarray.length; i++) System.out.println("myarray[" + i + "] = " + myarray[i]); array2 = copyArray(myarray); System.out.println("After the call to copyArray()"); for(int i = 0; i < array2.length; i++) System.out.println("array2[" + i + "] = " + array2[i]); } static void changeArray(int[] foo) { for(int i = 0; i < foo.length; i++) foo[i] = foo[i] + 1; } static int[] copyArray(int[] foo) { int[] bar = new int[foo.length]; for(int i = 0; i < foo.length; i++) bar[i] = foo[i]; return bar; } }