• Post Reply Bookmark Topic Watch Topic
  • New Topic

When to use Eclipse's enclosing type?  RSS feed

 
Siegfried Heintze
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was selecting eclipse's checkbox for an enclosing type when contemplating using implementation inheritance to solve a problem.

Eclipse created a new inner class that extended the outer class. This strikes me as very strange. When might this be useful?
Thanks,
Siegfried
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Imagine an interface or abstract class that can have only a few meaningful implementations. For example, a "Gender" interface that has two (or perhaps three) different possible specializations. In this kind of situation, it can make sense to put all the possible implementations inside the superclass/interface; then, for example, the classes would be named "Gender.Male" and "Gender.Female", which seems rather natural.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!