// see bottom of page 402 of Savitch // This is an example that I wish he gave -- his explanation of Java's // behavior in passing an array and changing its contents is unclear. // A method can change an object's variables. Since an array is an object // with elements acting like instance variables, a method may change the // values stored inside an array. public class savitch402 { public static void main(String[] args) { int[] a = {1,2}; print(a); doStuff(a); print(a); // Is $a$ changed? No! $a$ still refers to an array. // Are the contents of $a$ changed? Yes! } public static void doStuff(int[] x) { print(x); x[0]=3; x[1]=4; print(x); } public static void print(int[] x) { for (int i = 0; i