After 1000s of private
s in private
it occurred to me that it may not be needed
public class Outer {
private static class Inner { // you may drop static
private void innerMethod() {}
}
}
Is there any case that dropping private
from innerMethod()
would make a difference in encapsulation (or use, by Outer for instance) ? Think also reflection
If not is it recommended to drop it or keep it vis a vis coding style ?
I'd say no and drop but not sure really.
EDIT : just realized that the way I do it is certainly wrong - at least for Inner
's fields - declaring those fields private and then using them in the outer class - as this generates ("synthetic") accessors in the bytecode - which is at least bloat. Great - so now I am even more interested to have an account on the security implications of declaring those (Inner
's fields, methods used in Outer
) package private (or public as @JBNizet says in the comments)