[My Blog]
All roads lead to JavaRanch
SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
Christophe Verré wrote:(a=b) is evaluated first. For example : int[] c = (a=b); Here, a,b and c all refer to the b array.
Now, (a=b)[3] returns the fourth element of the array returned by (a=b), which is {2,3,1,0}. The fourth element is 0.
Finally, a[(a=b)[3]] is the same as a[0], thus the answer is 1.
SCJP 6.0 96%
(Connecting the Dots ....)
SCJP 6.0 96%
(Connecting the Dots ....)
Sahil wrote:But since a is assigned a reference b as a consequence of the statement (a=b), then a is pointing to array b and {1,2,3,4} should be abondoned.
[My Blog]
All roads lead to JavaRanch
OCPJP 6.0 93%
OCPJWCD 5.0 98%
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Abimaran Kugathasan wrote:
http://plainoldjavaobject.blogspot.in
Lalit Mehra wrote:
Abimaran Kugathasan wrote:
a[(a=b)[3]] is just like a(b[3]) since a=b so it prints '1' a b[3] evaluates to '0' so
a[(a=b)[3]] = a[b[3]] = a[0] = '1'
now the assignment of a = b takes place and then on applying a[0] it prints 2 since now a points to b
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|