This reference should be useful:
15.13.2 Examples: Array Access Evaluation Order
http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#23902 a[a[b]] = a[b] = b = 2; is evaluated as follows
0) The left-hand operand of a binary operator is evaluated first
1) a[a[b]] evaluates to a[0]
2) a[b] evaluates to a[0]
3) assignment is evaluated performed right to left
4) b = 2 assigns 2 to b and returns 2 to a[b]
5) a[0] = 2 assigns 2 to a[0] and returns 2 to a[a[b]]
6) a[0] = 2 assigns 2 to a[0] again and returns 2
No specific assignment is made to the other three array elements, so they still have the default int value of zero.
Therefore, a[0] = 2, a[1] = 0, a[2] = 0, a[3] = 0 are printed out.