Don't think of a static class as being a member of its enclosing class. It's a class of its own, totally separate. The only real distinction between it and a top-level class is that it has a slightly different name, and it can be private — which again doesn't affect its semantics, other than the fact that only the enclosing class knows about it.
So, if I have:
public class EnclosingClass {
public static class InnerClass {
}
}
Then anyone can come around and do:
EnclosingClass.InnerClass instance = new EnclosingClass.InnerClass();
See: exactly the same as a top-level class.
This is actually true of an inner class, too. There things are slightly more complicated, but basically the idea is that the inner class is still its own class, but it has a (mostly hidden) reference to the instance of the enclosing class that created it. I say "mostly" because it's possible to access that instance, via EnclosingClass.this
. The java compiler also does some convenience plumbing for you, such that someFieldInTheEnclosingClass
becomes EnclosingClass.this.someFieldInTheEnclosingClass
. But don't let that shorthand fool you: the inner class is its own separate class, and its instance is its own separate instance; they're no different than a top-level class in that regard.