I am learning inner class . Out of curiosity i extended the inner class which has a parameterized constructor. But when i write super(int i) to call it the code does not compile.
class Outer{
class Inner{
private int a;
Inner(int i){
this.a=i;
}
public void inheritFromInner(){
System.out.println("Inherited from inner");
}
}
}
class Test extends Outer.Inner{
Test(int r){
super(r);// This line does not compile.
}
}
As inner classes are part(member) of the outer class and they have to be accessed through the outer class. How the super constructor of Test class can be called.
The compile error is: No enclosing instance of type Outer is available due to some intermediate constructor invocation
You need to state your Inner class to
public static