First of all, if you don't want to quit the job and till be able to

get benifits from government( like here in Australia), please

do not write code like that! or next lay-out you will

be the first candidate.

There are two thing involved in this problem, one is

Evaluation order(see R&H page 33) and the other is the

Assignment Operators(see R&H page 65)

Evaluation order said that

JAVA scan a line of code from

left to right and decide what it is,

Assignment Operator run from right to left.

so when it sees this line of code :a[a[b]]=a[b]=b=2;

Evaluation first(from left to right)

first : a[a[b]]; as at right now b = 0, so a[b] is a[0]

also it decides a[a[b]] is a[0],

second : =a[b], because b is 0 ,a[b] just a[0]

third : b just b

the last : is 2

now it is time Assignment Operator(from right to left)

first : b=2, so now b is 2

Second : a[b]=b, it decided a[b] is a[0] so a[b]=b just a[0]=2

the last : a[a[b]]=a[b], as it decided a[a[b]] is a[0]

so this assignment just as a[a[0]]=a[0], which the same as a[0] =a[0]

which means a[0]=2

The result as a[0] = 2 the other 0 as before.