1) You can't call a constructor for an inner class from a static method (such as main) unless you explicitly provide an instance of the outer class: InheritInner ii = o.new InheritInner( ) 2) All variables defined in an interface are public, static, and final.
Ron, Actually InheritInner is not a nested class of Outer. It is just extending Outer.Inner. So, can I do that first of all?? I've tried though and got error. Let me explain my situation here one more time..
If I don't do, o.new InheritInner()at line 4 then I am getting error 'no enclosing instance of type Outer is in schope' for line 1. If I put o.new InheritInner() at line 4 then I am getting error 'Can not resolve Symbol class InheritInner' for line 4 which I think right as InheritInner is not an inner class of Outer. Any idea?? Niral
When you extend an inner class, the default constructors are no longer created... or they no longer work. When you try to create a class of InheritInner, you are also trying to create the sub-object Inner (which is the super class). But since, Inner is an inner class, you need a refrence to the enclosing class object. This can be acheived by passing the reference of the Outer class to the constructor of InheritInner & explicitly invoking the constructor of Outer. For the complete explanation, refer Bruce Eckel's Thinking in Java. Thats one hell of a book.
[ September 12, 2002: Message edited by: Vin Kris ]