So I was doing a UIL practice test and this problem came up.
public void fun(int[] list){ list[2]++; list[1] = list[0]; list = new int[4]; list[2]++; } ////////////////////////// // client code int[] vals = {2, 7, 3}; fun(vals); out.print( Arrays.toString(vals) ); I tried it out and got [2, 2, 5] but the answer was [2, 2, 4]. Since it was just list[2]++, I figured that it would just add, but it didn't. Why was the last increment not included in the output?