推荐的做法是如果非要使用内部类的话,请使用静态内部类。
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.
Scala是静态类型的,这就允许它提供泛型类、内部类、甚至多态方法(Polymorphic Method)。
Scala is statically typed which allows it to provide generic classes, inner classes and even polymorphic methods.
Scala是静态类型的,这就允许它提供泛型类、内部类、甚至多态方法(Polymorphic Method)。
Scala is statically typed which allows it to provide generic classes, inner classes and even polymorphic methods.
应用推荐