This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
It is useful when you've got a class Foo that uses another class Bar, and this class Bar should not be used or cannot be used by any other class but Foo. Making class Bar a default (package-level) access class would enable it to be used by other classes in the package (which you don't want) and just clutter up the package besides. A good example is the java.util.Collections class. All the wrapper methods (Collections.synchronizedCollection(), Collections.unmodifiableCollection(), etc) return instances of private, static nested classes of java.util.Collections. None of these should be used directly by any class other than Collections itself, and there are enough of them to cause quite a bit of clutter in java.util. Another (weaker) reason to use static nested classes is to express that two classes are very closely related. Admittedly, they are interfaces rather than classes, but look at java.util.Map and Map.Entry. Making this a nested interface (which is always static) expresses something about the relationship between Entry and Map. It won't surprise you to find that a Map implementation such as HashMap contain a (private) static nested class Entry that implements Map.Entry. - Peter
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: What is a practical example of a nested static class