What's the advantage of making an inner class as static with Java?

后端 未结 6 1288
梦毁少年i
梦毁少年i 2020-12-13 18:21

I have an inner class in my Java class.

\"enter

When I run find bugs, it recom

6条回答
  •  醉酒成梦
    2020-12-13 19:21

    Benefits of static inner classes:

    1. Instantiation of static inner class does not rely on external class guidance, and the memory overhead of instantiation.
    2. Static inner class does not hold external class guidance, does not affect the collection of external class, to avoid the extension of the external class in memory survival time leading to memory leakage.

提交回复
热议问题