I've made a lot of use with static inner classes. I'm curious about what really goes on with an inner class that isn't static. I know that I can, inside a static inner class, refer to a member of the outer class, either a variable or a method. But that kind of confuses me. Can anyone think of somewhere I can go to read what actually happens when an inner class refers to a member of the outer class? I'm aware of the possibility that the Java Docs may discuss this, but I have no idea where to go in the Java Docs to find such a discussion.
All inner classes are non-static. The definition of an inner class is, roughly, "a non-static nested class," although last time I dug into it there seemed to be a bit of ambiguity or inconsistency in the JLS on that distinction.
One thing to be aware of is this: an instance of an inner class is associated with an instance of its enclosing class. (That's also why you can access member variables from the enclosing class inside the inner class).
When you create a new instance of the inner class in a constructor or non-static method of the enclosing class, the enclosing class instance that the inner class instance will be associated with is the 'this' of the enclosing class.
When creating a new instance of the inner class in a static context (for example, a static method of the enclosing class), you must explicitly indicate the instance of the enclosing class that the inner class instance must be associated with. You do this by calling the new operator for the inner class on an instance of the enclosing class.