why is the line(3) not ok and why is line(5) ok though it is non-staic member.can anybody please explain this? [ Jess added UBB [CODE] tags to preserve whitespace so the code is more readable ] [ June 24, 2002: Message edited by: Jessica Sant ]
Line 5 is acceptable because this inner class extends the class SuperB. Therefore, you're really accessing the member variable x within the inner class instance of StaticLocalE. Corey
First of all, I'm assuming that the method staticMethod is really supposed to be static. Otherwise, we don't have this problem. The issue is that the variable y, defined within class SuperC, is an instance variable. You can't access an instance variable from a static context...EVER! An instance member requires an instance to be a part of. From a static context, you have no instance for that member to be part of, so you can't access it from there. The converse is not true. You can access static members from a non-static context. Corey