Question on associativity and precedence



int[] z = {10,20,30,40,50};
int index = 4;
z[index] = index = 2;

System.out.println(z[0]);
System.out.println(z[1]);
System.out.println(z[2]);
System.out.println(z[3]);
System.out.println(z[4]);



This code gives

10
20
30
40
2

Why does it not give:
10
20
2
40
50

Why z[2] is not assigned 2?? How can this be explained in terms of
associativity and precedence rules.
.