The rule wants me to declare visibility explicitly. That’s very fine. I support that.
But in the following case it is wrong.
public class A
{
private static class B
{
int i; // FP
}
private void test()
{
B b = new B();
int i = b.i;
}
}
For private inner classes (not necessarily static) the no-modifier is not only handy, but exactly correct. Private would work, but no-modifier officially allows me to access from outside the (inner) class.
Also for closures this should be ignored, even if in this case it’s better to declare private.
public Supplier< Integer > foo()
{
return new Supplier<>()
{
int counter = 0; // FP
@Override
public Integer get()
{
return ++counter;
}
};
}