I have this small code
class OuterTrial{
int y = 9;
class InnerTrial{
int hello = 8;
}
static public void main(
String[] Args){
OuterTrial outer = new OuterTrial();
OuterTrial.InnerTrial inner = outer.new InnerTrial();
}
}
Everything works just fine. No compilation error.
But if I change the last line to
outerTrial.InnerTrial inner = new InnerTrial();
it gives me this compilation error:
OuterTrial.java:15: No enclosing instance of class OuterTrial is in scope; an explicit one must be provided when creating inner class OuterTrial. InnerTrial, as in "outer. new Inner()" or "outer. super()".
OuterTrial.InnerTrial inner = new InnerTrial();
^
i understand outer.new Inner() and it works fine when i write
"OuterTrial.InnerTrial inner = outer.new InnerTrial();" in the code above.
but I don't know how to use outer.super();
it doesn't work when i use
"OuterTrial.InnerTrial inner = outer.super();"
I also don't understand why should someone use super() with the outer Object.
Thanks
alot.
Purvi