Java语言允许在类中再定义类,这种在其它类内部定义的类就叫内部类。内部类又分为:常规内部类、局部内部类、匿名内部类和静态嵌套类四种。
推荐的做法是如果非要使用内部类的话,请使用静态内部类。
The recommended approach is to use static inner classes, if you must use an inner class at all.
编译器完全禁止在静态方法和静态内部类中引用封闭类型参数。
Referring to enclosing type parameters inside static methods and static inner classes is prohibited outright by the compiler. So, for instance, the following code is illegal in tiger.
内部类会在外部类中任何需要访问mValue字段或调用doStuff方法的地方调用这些静态方法。
The inner class code calls these static methods whenever it needs to access the mValue field or invoke the doStuff method in the outer class.
应用推荐