为什么要有内部类?

  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.

你可能感兴趣的:(为什么要有内部类?)