Note: I typed this all up, but then realized the topic got locked (for good reason). I'm just going to post my comment even though Henry has given you an answer.
Yes, there is a way. The rules get moderately complicated.
What you need to do is to pass a reference of an innermost enclosing parent class of a class that you are extending, and call its
super(). So, let's expand on your example,
A class that you are extending is
Main.Inner.NestedInner and its innermost enclosing parent is
Main.Inner, so we must pass its reference to
Demo's constructor.
"Since an inner object can not exist without an instance of the enclosing class, the constructor for the inner class should have the enclosing class as one of the arguments; this is automatically provided by the compiler generated code in the class file. In addition, the first statement in the constructor should invoke the super class constructor with the following syntax:
<enclosing instance>. super(). If the inner class that is extended has several layers of nesting, the enclosing instance immediately above the inner class is passed."
Now, if the constructor of a class that is being extended passes arguments, due to inheritance rules,
you should call that particular constructor rather than the default one (
super()). You are allowed to pass arguments to an overloaded constructor of a class that is extending an external inner class -- it's just that you need to, as I said, first, pass the parent of an innerclass extending class, then call its
super().