Inspectopedia
 
2024.3

Inner class may be 'static'

Warning
New
Last modified: 03 December 2024

Reports inner classes that can be made static.

A static inner class does not keep an implicit reference to its enclosing instance. When using Java 17 or before, this prevents a common cause of memory leaks and uses less memory per instance of the class.

Example:

After the quick-fix is applied: