It's a little confusing to say that a nested class is quite different from an inner class - an inner class IS a nested class. As per the JLS, any class defined within another class is a nested class, and a top-level class is any class which is not nested. Note that this renders the term "top-level nested" an oxymoron.
Using "inner" to describe those classes which require an enclosing instance of their enclosing class seems to be the most natural and useful use of the term, but the JLS throws a curve here. The JLS has it that an inner class is any nested class which is not declared static. This turns out to be every nested class other than a static member class - a useless distinction.
Actually, the JLS says: "An inner class is a nested class which is not explicitly or implicitly declared static." (8.1.2). If local and anonymous classes declared in static contexts can be considered "implicitly declared static", then the term "inner" means what we would like: needs an enclosing instance.
But the JLS nixes this in 14.3 and 15.9.5, where it states (arbitrarily?) that anonymous and local classes are always inner. It's as if the JLS forgets that local and anonymous classes can be declared in static contexts, where they have no enclosing instance. I believe this is a JLS bug. If it just didn't say that anonymous and local classes are always inner, we could use the term "inner" where we need it - or maybe people are ignoring the JLS and doing this anyway, as in
inner story.
Actually, I think this problem and much of the obscurity of nested classes would disappear if inner (JLS sense) classeswere allowed to have static members, but I suppose this is another topic.
[ April 02, 2004: Message edited by: Steve Lovelace ]