Java 从多层嵌套中访问内部类的成员
一个内部类被嵌套多少层并不重要--它能透明地访问所有它能嵌入的外围类的所有成员
//: innerclasses/MultiNestingAccess.java // Nested classes can access all members of all // levels of the classes they are nested within. package object; class MNA { private void f() {} class A { private void g() {} public class B { void h() { g(); //in class A 调用 g(),f(), 完全不需要任何条件 f(); } } } } public class MultiNestingAccess { public static void main(String[] args) { MNA mna = new MNA(); MNA.A mnaa = mna.new A(); MNA.A.B mnaab = mnaa.new B(); mnaab.h(); } } ///:~