An explicit enclosing instance of class 'identifier' is needed to call constructor of superclass 'identifier'
The compiler detected an attempt by a derived class to call its superclass constructor without an instance of the superclass. This error usually occurs because the superclass is also an inner class. When a derived class is instantiated, an instance of its superclass is also created (and the superclass constructor is invoked). In order to create an instance of an inner class you must instantiate the inner class using an instance of its outer class.
The following example illustrates this error:
class OuterClass{
class InnerClass{
//do something here
}
}
public class Simple extends OuterClass.InnerClass{
//do something here
}
/*error: superclass 'InnerClass' cannot be instantiated without its outer class 'OuterClass' being instantiated */
The following example illustrates how to instantiate a class that is derived from an inner class:
class OuterClass{
class InnerClass{
//do something here
}
}
public class Simple extends OuterClass.InnerClass{
Simple(){
/*this line creates an instance of the outer class and calls
the superclass (the inner class) constructor */
new OuterClass().super();
}
}