内部类与外部类的关系一

2018-10-01  本文已影响0人  泰兰德的加长香蕉

  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.

上一篇 下一篇

猜你喜欢

热点阅读