Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about inner classes

 
Rajesh Tarigopula
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
we can declare an inner class as abstract or final. Then where and how we can impliment the abstract methods of an inner class and what is the meading of making an inner class final.

Similary if we declare an inner class as method local with abstract or final
then where and how we can impliment the abstract methods of an inner class and what is the meading of making an method inner class final.

how can we inherit an inner class if it is not final.

Thanks & Regards
Rajesh
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes an inner class can be abstract or final (but not both).
A final inner class simply cannot be inherited from.
An abstract inner class cannot be instantiated and typically contains one or more inner classes (less common that final inner classes in my experience).

Hope this helps.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could do something like this:


how useful that is remains to be seen
Probably you could also declare the outer class as abstract and defer implementation of the abstract inner class to childclasses of the outer class like this: (I haven't tried any of this, mind)


which seems more useful by far.

P.S. corrected code so it now compiles (doh) and indeed it compiles.

[ October 20, 2004: Message edited by: Jeroen Wenting ]
[ October 20, 2004: Message edited by: Jeroen Wenting ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic