• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use of static inner classes

 
Paul Barnes
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to figure out the purpose of using a static inner class...
1. Why wouldn't you just create a package level static class instead of a static inner class which ends up being equivalent to a package level static class anyway?
2. What are the pros of cons of using them?
3. And can anyone give me an instance of some code where a static inner class was used a data store for general use by the system?
Thanks for helping me to understand this...
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's one way of controlling namespace.
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even if you declare the class as static other classes can see it. The inner class lets you hide from everyone.
 
Shanee Bradley
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are useful to hide a node class in a Linked list or hide an iterator...all kinds of uses.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic