“public” or “protected” methods does not make any difference for a private nested class which does not implement any interface ..?
If a private nested class does not implement any interface or inherit from any class, for the modifiers of its methods , it seems “public” or “protected” or no modifier do not make any difference. It would make more sense if the compiler allows “private” only for them. So why does java allow them?
class Enclosing {
private class Inner {
private void f1() {}
void f2() {}
protected void f3() {}
public void f4() {}
}
void test() {
Inner o= new Inner();
o.f1();
o.f2();
o.f3();
o.f4();
}
}