inner calss and anonymous clas 得区别

Nested Class 分为inner class 和static nested class这两种。

inner class分为三种,第一种,inner calss,第二种是method inner class,第三种是anoymous inner class

其中:anoymous inner calss 分为两种,第一种是没有;无类名得 inner class类,第二类是使用参数传递的inner class,

新建的anonymous inner class直接作为一个参数进行传递。

这几种inner class 都会对outer class 进行引用的

 

最后的一种是outer nested class类,这个类不会引用outer class,所有不造成内部类的内存泄漏。class名字前面加个static的变量

posted on 2018-11-25 13:55  tistar  阅读(215)  评论(0编辑  收藏  举报