• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Anonymous inner class

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can I extend and implement an anonymous inner class? What is the syntax if say Super is the super class and MyInt is the interface I want to implement?
 
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sue Pillai:
Can I extend and implement an anonymous inner class? What is the syntax if say Super is the super class and MyInt is the interface I want to implement?



If you mean, "Can I extend an anonymous inner class?". Then the answer is no. They are implicitly final.

If you mean, "Can I write an anonymous inner class that extends a class and implements an interface"? If so, then no. You can write an anonymous inner class that either extends a class or implements an interface.

To implement an inteface, you would use:



To extend a class you would use:




Hope this helps, if you have more questions, just ask.

You may also find this article helpful:

developer.com: SJCP Exam Preparation
 
Sue Pillai
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. sorry I didn't put the question right. I meant the latter. That was a good article. Thanks again.
 
Don't touch me. And dont' touch this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic