Consider the below code:
class abstract Normal1 extends Something
{
}
class Outer
{
class abstract Inner extends Normal1
{
}
}
class General extends Outer.Inner // Problem occurs at this
{
}
The error I am getting is "No enclosing instance of type PerfHelper is available due to some intermediate constructor invocation"
My question is can I extend the inner class like above ?
Declare the inner class as static and you should be able to extend it:
class outer {
static abstract class inner extends normal1 { }
}
If inner is not abstract, it's tied to outer, and can only exist when an instance of outer exists. Check to see if this is what you really want.
Nested class are like(in sense ) Property of a class.
inner
class also available when outer's object will created.So if you want to extend this then make your inner class as static inner class
As jordao suggest above
Try this, (Read nested class inheritance rules).
abstract class normal1 extends something { }
class outer
{
abstract class inner extends normal1{}
}
class Outer1 extends outer
{
class General extends inner {}
}
In your class General modify its constructor a to call super inner class constructor. here is the code..
public General(){
new outer().super();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With