posted 21 years ago
For another use of a nested interface, check out java.util.Map.Entry. The Map interface needed to make use of another interface, Entry. The Entry interface is really only used in connection with a Map - so while it could have been defined in a separate file, it's a bit cleaner to define it within the Map interface. This is one of the primary uses of static member classes - defining a class that, while it could have been a top-level class in a separate file, is so closely tied with another class that you'd really rather define it in the same file. It only makes sense to allow this for interfaces as well as classes.
Map.Entry is an interface nested in an interface; it's also possible to have an interface nested in a class, or a class nested in an interface - though I don't know of an example of these offhand. All these are necessarily static member classes or interfaces - any class or interface nested in an interface is implicitly static, and any interface nested in a class is also implicitly static. So even if you don't declare them as static, they are.
"I'm not back." - Bill Harding, Twister