For the above code, the compile time error generated is :
No enclosing instance of type Main is available due to some intermediate constructor invocation. Does this error indicate that there is some other way to extend an inner class by code outside the top level class?
Can someone help by explaining the error statement?
Cyril Sadasivan wrote:
No enclosing instance of type Main is available due to some intermediate constructor invocation.
fine. when you say , then compiler define a default constructor for you as
note here super() means you are accessing the Inner class constructor directly, which is not possible since inner class bound to an outer class instance.
i.e, to access non-static inner class member you should access via outer class instance. hence access inner class constructor as some thing like below