Originally posted by FEI NG:
Make sure you know them all.
Top level nested class. (static)
none-static nested class (none static)
inner class ( static and none)
anonymous class ( staic and none)
The summary referred to is useful, but terminology will always be an issue
While the passport book was written, we found that terminology regarding inner classes is a complete mess.
The Java Language Specification uses the term "inner class" for all non-static classes defined within another class:
An inner class is a nested class that is not explicitly or implicitly declared static. [...] Inner classes include local (�14.3), anonymous (�15.9.5) and non-static member classes (�8.5). It excludes all static nested classes, which makes sense, because they don't have that implicit association with an instance of the outer class.
So far, so good. Unfortunately, elsewhere Sun seriously confuses matters by using the term "inner class" to include static nested classes, and confusion reigns everywhere. The summary quoted above, for instance, uses the term "inner class" for non-static member classes and nothing else - yet another definition!
There's also a slight inaccuracy in the summary - inner classes (of any kind)
can define constant members, so the prohibition of static members is not absolute.
- Peter