| Author |
operator precedence and arrays
|
preeti khane
Ranch Hand
Joined: Mar 12, 2003
Posts: 93
|
|
Can someone explain what's happening at line 7
|
 |
Praveen Kumar Mathaley
Ranch Hand
Joined: Apr 14, 2003
Posts: 45
|
|
System.out.println(a[(a=b)[3]]); let's consider how it's interpreted. processing of the statement start from left to right (a=b) get's evaluated which assigns a to the reference held by b this means now 'a' is pointing to array {0,1,2,3} now the computation would be a[a[3] but here lies the trick, the outer 'a' reference was held before evaluating the argument. so the outer reference prints the 4th element of the array {11,12,13,14) try inserting the line System.out.println(a[3]) at the end, it will print 3!
|
 |
 |
|
|
subject: operator precedence and arrays
|
|
|