I have declared one of my class variables as final and in the method defined in that class i declared one of my method variables as final.Here i am getting compilation error when i am trying to change the both the variables. But I have defined one more method in the same class with the method argument as final variable.But it wont be showing any compilation error when i am trying to change the value.
Can anyone explain me the reason why is this happening.
At (1), you definitely assign "n" the value 0, which is a final variable. At (2), you are trying to re-assign a value to "n", a final variable, which already is definitely assigned a value at (1). This is the error in your program; its not possible to change the value of 'n' once you have definitely assigned it a value. Hope clarified the confusion.
Regards, Abdul Rehman. [ November 23, 2006: Message edited by: Abdul Rehman ]
SCJP 5.0 (100%)
I don't get it. A whale wearing overalls? How does that even work? It's like a tiny ad wearing overalls.