以下内容无法编译:
class Outer<T> {
class Inner {
}
static class Nested {
Inner inner; // Error: Outer.this cannot be referenced from a static context
}
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我删除<T>,它会编译.为什么不一致?
另外,如果我说Outer.Inner inner;,而不是Inner inner;,它编译.再次,为什么不一致?
我希望在所有情况下都是错误,或者没有错误.谁能解释一下发生了什么?