Daniel Martins wrote:Hi
I do not understand this syntax...
SCJP 6
Ankur kothari wrote:hey here doesnt assigning b to a will change the value of a...i mean
a=b will be evaluated thus a will be {2,3,1,0}
thus the expression would be {2,3,1,0}[{2,3,1,0}[3]]...isnt it.
i know there is something wrong
please correct me
SCJP 6
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankur kothari wrote:
what do you think will be the answer?
100 or 90?
SCJP 6
Ankur kothari wrote:yes the answer is 90...what i meant is that this works not only for arrays.....gotto look at the jls link ankit gave
15.13.1 Runtime Evaluation of Array Access
SCJP 6
Ankur kothari wrote:yes punit you were right but what explains x*(x=y) expression?
hey here doesnt assigning b to a will change the value of a...i mean
a=b will be evaluated thus a will be {2,3,1,0}
thus the expression would be {2,3,1,0}[{2,3,1,0}[3]]...isnt it.
i know there is something wrong
please correct me
SCJP 6
SCJP 6
Ankur kothari wrote:oh yes left to write....
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankur kothari wrote:if we have to learn a language we have to speak it....that is why i love javaranch
SCJP 6
SCJA 1.0
Chintan writes:
Why would this print 90? Wouldn't expression within brackets(x=y) have precedence over *?
Sage of The Monstrous Toad of Mount Myoboku
Punit Singh wrote:
Ankur kothari wrote:hey here doesnt assigning b to a will change the value of a...i mean
a=b will be evaluated thus a will be {2,3,1,0}
thus the expression would be {2,3,1,0}[{2,3,1,0}[3]]...isnt it.
i know there is something wrong
please correct me
That was the main funda in this question, everybody in starting thinks like you think, even I thought that way, but after running the example I got it that it is evaluating in different way, means left a evaluated before a=b is evaluated. It has some relationship with array expression evaluation. We need to discuss it further.
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
SCJA 1.0
rohan yadav wrote:
Chintan writes:
Why would this print 90? Wouldn't expression within brackets(x=y) have precedence over *?
Hi chintan, printf statement evaluates from left to right, hence first value of x is 9 and after assignment x is 10 hence answer is 90.
MCP, AWS Certified Developer Associate, Preparing for OCPJP...!!
This parrot is no more. It has ceased to be. Now it's a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|