内部类与外部类的关系一

  Traditionally, a method could refer to the data fields of the object invoking the method. An inner class method gets to access both its own data fields and those of the outer object creating it. For this to work, an object of an inner class always gets an implicit reference to the object that created it.

  The outer class reference is set in the constructor. The compiler modifies all inner class constructors, adding a parameter for the outer class reference.

你可能感兴趣的:(内部类与外部类的关系一)