This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Anonymous inner class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Anonymous inner class" Watch "Anonymous inner class" New topic
Author

Anonymous inner class

Sue Pillai
Ranch Hand

Joined: Nov 04, 2004
Posts: 89
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?


Sue

SCJP 1.2
SCWCD 1.4
SCBCD 5.0
Horatio Westock
Ranch Hand

Joined: Feb 23, 2005
Posts: 221
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

Joined: Nov 04, 2004
Posts: 89
Thanks. sorry I didn't put the question right. I meant the latter. That was a good article. Thanks again.
 
Don't get me started about those stupid light bulbs.
 
subject: Anonymous inner class
 
Similar Threads
A question about anonymous inner class?
Another anoymous question