[Henry]: It's an inner class Oh, so
you're one of the (former) Sun employees responsible for muddying the waters about the definition of terms like "inner" and "nested".
It would have made a lot of sense if Sun had officially adopted definitions that made inner classes and nested classes the same thing - but they didn't. By definition, a static nested class is
not an inner class. Because inner classes are, by definition, not static. All classes are either top-level classes or nested classes. All nested classes are either static classes or inner classes. Any time someone refers to a static inner class, assume they mean a static nested class - but treat everything else that person says about "inner" classes with suspicion, because apparently they've rejected the official definition, and who can tell
what they mean in that case.
I should note that Henry is among my favorite JavaRanchers, and I have great respect for him. But terminology is important. It's unfortunate that Sun didn't choose more logically intuitive terminology, but it's been, what, eight years or so since Sun published the Inner Classes Specification? OK, bad example, since it was so logically inconsistent and poorly-named. Seven years since they published the JLS second edition, which incorporated most of the inner classes spec while removing the self-contradictory crap. Yes, the compiler still sometimes issues error messages which were evidently written by engineers unfamiliar with the specs, but oh well.
[Tarek]: So can outer classes be static? Outer classes can never be static. Or rather, the term "static" is irrelevant to outer classes - though I would say that outer classes are more like static nested classes than they are like inner (non-static) classes. When applied to classes, "static" is only meaningful in defining how a nested class relates to its containing class.
And why isn't the special "class" variable mentioned in the API docs? Where should it be mentioned? It's not an attribute of any one class - it's an attribute of
all classes. They could define it in every single class, but that seems wasteful. And they can't define it in Object, because it's different for every class. It's like a static field, although technically it's not a field or variable at all. Anyway, it's defined in the
Java Language Specification, section 15.8.2.
[ September 22, 2007: Message edited by: Jim Yingst ]