这里有两种说法,我发现有关内部类内部类继承和访问封闭类的方法/字段
的JavaDoc:
As with instance methods and variables, an inner class is associated with an instance of its enclosing class and has direct access to that object's methods and fields. Also, because an inner class is associated with an instance, it cannot define any static members itself.
在另外一个网站,我发现这一点:
A nested class, for the most part, is just that—a class declared in the definition of an enclosing class. It does not inherit anything from the enclosing class, and an instance of the nested class cannot be assigned to a variable reference to the enclosing class.
大胆的标志线不矛盾吗? 如何不能继承周围的对象字段和方法,并同时访问其字段和方法?
继承和访问是两个不同的事情。 – SomeJavaGuy