If I have a class with two static
nested classes, is there any way to restrict access of private static
fields in one class from the other? Example:
public class Outer {
private static class Inner1 {
private static int privateInner1 = 0;
private Inner1() {
System.out.println(privateInner1 + ", " + Inner2.privateInner2); // prints "0, 1"
}
}
private static class Inner2 {
private static int privateInner2 = 1;
}
public static void main(String[] args) {
new Inner1();
}
}
Not that I actually have a use case for this in mind, I'm just curios.
Thanks!