Originally posted by Netty poestel:
I had a doubt on the line "case x-1:..."
afaik, x is final and it is not supposed to be changed. but it seems saying something as "case x-1" is perfectly allright.
can someone explain why mutilating a final variable is allowed ?
TIA
Netty
First lets go for the rule regarding case argument's i.e. case arguments must be final i.e. the value of the case argument must be known at compile time.
Secondly
case x-1: is allright bcos we are not changing the value of x anywhere.
During compilation the case x-1 is interpreted as
case 2-1 i.e case 1
See nowhere the value of x was changed...
x-1 doesnt (attempt to) change the value of x ... but x++ , x--, ++x,--x does.
Also your above code wont compile since variable y is not final.
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.