Originally posted by biny panackal:
which i am changing here.
All your accesses of "i" are accessing the instance field, via a reference to an object of class "b". Therefore, they are all legal.
Your method-local variable "i" hides the instance field "i". So, if your code in main() accessed "i" without reference to an object of class "b", it would be a legal, too.
If you didn't hide the field "i" with a method-local variable, then you tried to access "i" without reference to an object of class "b", it would be a compile error.
Because this stuff can confuse the reader,
you should aim never to hide a field with a method-local variable. It is legal, but bad practice.
[ October 17, 2007: Message edited by: Peter Chase ]