我推测你想从一个封闭的实例外部扩展一个非静态的内部类,这是可能的.
class Alpha
{
class Beta ( ) { }
}
class Gamma extends Alpha . Beta
{
// important to get the constructor right or else the whole thing fails
Gamma ( Alpha alpha )
{
alpha . super ( ) ;
}
}
Run Code Online (Sandbox Code Playgroud)
您还可以在原始封闭类中扩展内部类
class OuterParent
{
class InnerParent { }
class InnerChild1 extends OuterParent { }
}
Run Code Online (Sandbox Code Playgroud)
或者扩展原始的封闭类并扩展子类中的内部类
class OuterChild extends OuterParent
{
class InnerChild2 extends OuterParent { }
}
Run Code Online (Sandbox Code Playgroud)