为什么要有内部类?

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

  An inner class is a class that is defined inside another class. Why would you want to do that? There are three reasons:

• Inner class methods can access the data from the scope in which they are defined—including the data that would otherwise be private.

• Inner classes can be hidden from other classes in the same package.

• Anonymous inner classes are handy when you want to define callbacks without writing a lot of code.

上一篇 下一篇

猜你喜欢

热点阅读