This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inner class, when ??

 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
could any one tell me the use of inner classes ??
when is it used ??
thanks
raj
 
Frank Hale
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its probably a matter of preference when to use it. However its extremely useful when adding listeners to Swing components. Thats where I've seen it used extensively.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have a class that is so tied to another class that it makes no sense for the one class to exist without the other.
An example from the API is the Entry class which is an inner class of the Map class. Entry represents a key-value pair in a Map so it makes sense to make Entry an inner class of Map.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic