Suppose I have an outer class with an inner class inside. The inner class has four fields with all possible access modifiers.
class Outer {
private class Inner {
public int publicField;
protected int protectedField;
int packagePrivatefield;
private int privateField;
}
void doSomethingWithFields() {
Inner inner = new Inner();
inner.publicField = 111;
inner.protectedField = 111;
inner.packagePrivatefield = 111;
inner.privateField = 111;
}
}
The inner class is private, so I can't create instances of it outside the Outer class. Inside the Outer class, if I create an instance of the inner class and try to change the value for each of the fields I will succeed to do that. So I see that there is no sense in access modifiers for the above fields. Is there?
Edited: The main question is: Which access modifiers should I choose for members of the private inner class? Inner class can not only implement interface. I can put some difficult structure with logic into it.