Are Inner Classes lightweight?

后端 未结 3 2017
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-02 12:43

Are inner classes more lightweight than normal classes, or in the end java compiles inner classes just like normal classes?

I know classes in java are not all very l

3条回答
  •  孤独总比滥情好
    2021-01-02 13:39

    Inner classes are still classes and they still have to be loaded by a ClassLoader. If anything, the opposite is true. A non-static inner class can keep the parent class from being garbage collected since it has a reference to the class which owns it.

提交回复
热议问题