File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Advantages of inner classes

 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the advantages of inner class?
 
Chris Stehno
Ranch Hand
Posts: 180
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are many advantages, though some of them are really personal or design preference.
1 - with inner classes you can access private members of the enclosing class.
2 - they are useful for interface implementations that are only used by the enclosing class (event handlers in a application)
3 - they are useful for providing fine grained access and creation control over an interface implementation that is retrieved externally (maybe something like an Iterator implementation)
Once you learn how to use them effectively you will wonder what you did without them.
Hope this helps.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're likely to stumble upon a few good past conversations on inner classes when trying a search on one of the Java in General forums or the OO forum.
Note that the search page link is at the top right of this page.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic