I am looking through some old questions for a test and I come across a quite easy question however it wasn't what I expected.
public class Exampractice {
  public static void f(int x, int[] y, int[] z) {
    x = 2;
    y[0] = x;
    z = new int[5];
    z[0] = 555;
  }
  public static void main(String[] args) {
    int x = 111;
    int[] y = {222, 333, 444, 555};
    int[] z = {666, 777, 888, 999};
    f(x, y, z);
    System.out.println(x);
    System.out.println(y[0]);
    System.out.println(z[0]);
  }
}
The question asks what is the result of the following code. I get the following results:
111 
2 
666 
I understand why x is 111 as local variables override all other variables, y[0] =2 as the code says it equals x which is 2 but I am lost on why z[0] = 666 as it has been rearranged in the f class.
 
     
     
     
     
     
     
    