You are actually accessing the local variable "i" and not the one declared in the class scope. Since the main method also declares a variable named 'i', this local variable hides the instance variable "i". Cheers! ------------------ Ajith Kallambella M. Sun Certified Programmer for the Java�2 Platform. IBM Certified Developer - XML and Related Technologies, V1.
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
does that mean a static method can access non-static local variables?? Hima, 1) The static/non-static modifiers does not applies to local variables. 2) local variables scope is local, and does not exist after the method is executed. (With the introduction of inner classes, this is not completely true. Because final local variables used by local inner classes can exists even after method completes its execution!) Best wishes! Rajesh