Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Re:inner classes

 
sunil kumre
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the need for having inner classes?
 
John Wetherbie
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Inner classes are good to use in cases where the inner class is tightly coupled to the class it is inside of. The inner class is doing working for the outer class that the outer class shouldn't be directly responsible for. I've seen/used inner classes as iterators, event handlers, and implementation providers.
John
 
Rick Edgecombe
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They also make code easier to read (in most cases). And, as we all know, readable code is maitainable code.

------------------
 
Tony Chen
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just read this article @ JavaWorld:
Java Tip 106: Static inner classes for fun and profit
[This message has been edited by Tony Chen (edited January 30, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic