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

Anonymous Class (interface & extends)

 
faisal usmani
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

Can an anonymous class be declared as implementing an interface and
extending a class ?


Thanx in advance
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. If you need to do both, then you'll need to use a named class (which could still be an inner class, just not an anonymous one.)
 
faisal usmani
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Ernest

But can you give me a little detail why is it not possible ?



-No act of kindness, no matter how small, is ever wasted
regards
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just because the language specification provides no way to do it. I suppose the logic was that if you need to do anything that complicated, then it's worth creating a class with a name. Anonymous classes are supposed to be tiny one-liners -- anything larger belongs in a named class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic