我研究Java内部类。
我编写了一个示例:
public class Outer {
public Outer(int a){}
public class Inner {
public Inner(String str, Boolean b){}
}
public static class Nested extends Inner{
public static void m(){
System.out.println("hello");
}
public Nested(String str, Boolean b , Number nm) { super("2",true); }
}
public class InnerTest extends Nested{
public InnerTest(){ super("str",true,12); }
}
}
我在主函数中使用以下字符串调用它:
new Outer(1).new Inner("",true);
我看到编译错误:
java: no enclosing instance of type testInheritancefromInner.Outer is in scope
你能为我解释一下这种情况吗?
更新
testInheritancefromInner
是什么? - Abimaran Kugathasan