内部类怎么用?一般什么时候用?
我是否可以理解成,我需要的一个类(inner class)有且只有在另外一个类(外部类)中使用就可以把这个类做为inner class定义在外部类中.

解决方案 »

  1.   

    如果仅仅是这么一个原因, SUN根本就不值得费心的增加这个特性.
      

  2.   

    So the most compelling reason for inner classes is: Each inner class can independently inherit from an implementation. Thus, the inner class is not limited by whether the outer class is already inheriting from an implementation.
    内部类还涉及到控制框架的问题, 实在不是几句话能说清楚的, 自己看Thinking in java吧, 为什么要使用内部类分析的特别透彻.