Reports any inner classes that can be made static
.
A static
inner class does not keep an implicit reference to its enclosing instance.
This prevents a common cause of memory leaks and uses less memory per instance of the class.
Example:
public class Outer {
class Inner { // not static
public void foo() {
bar("x");
}
private void bar(String string) {}
}
}
After the quick-fix is applied:
public class Outer {
static class Inner {
public void foo() {
bar("x");
}
private void bar(String string) {}
}
}