Prithvi Sehgal wrote:
3- After this point inside the loop where x is again incremented, i think x should be incremented to 9 which happens but shouldn't first value
8 be used and then in next iteration value 9 used.
SCJP 6
SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
Srinivas Nagesh wrote:I havent reached that part in the book but I think this is what happens when you execute the program
1. x is initialized to 7 in line 4
2. x is incremented to 8 in line 32
3. x is incremented to 9 in line 10
4. when the switch stmt is executed for the first time, the value of x is 9. which means case 9 would be resolved.
I am not sure why would you say x would have a value of 8 in the first iteration of the loop?
be a well encapsulated person, don't expose your privates, unless you public void getWife()!
Prithvi Sehgal wrote:Guys,
I completely understand the logic and everything in this question, my doubt may be i am unable to clarify. Let say for suppose.
Because in line 2 first previous value of x is used and then incremented.
I know i am stuck at a very silly confusion but still any pointers in this regard will be helpful.
be a well encapsulated person, don't expose your privates, unless you public void getWife()!
Prithvi Sehgal wrote:Guys,
At line 1, first the value of j is printed which is 9 and then incremented. My question was shouldn't when this block of code is reached
Shouldn't in the above code snippet even first value of x which is 8 should be used and and at next iteration 9 to be used.
Or there is some difference between these two statements
Because in line 2 first previous value of x is used and then incremented.
I know i am stuck at a very silly confusion but still any pointers in this regard will be helpful.
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |