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 classes 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 classes" Watch "anonymous classes" New topic
Author

anonymous classes

rachana ravali
Ranch Hand

Joined: Jun 20, 2006
Posts: 32
can an anonymous class extend a class or implement an interface?
please explain to me.
i am new to java.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
Welcome to the Ranch.

The short answer to both your questions is yes. In fact if it doesn't do one or the other, you have to give it a name, and it ceases to be anonymous.

You will find this is discussed many a time on the Ranch; different people have different opinions. Look at this thread in the advanced forum, for example.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: anonymous classes
 
Similar Threads
Passing an object to a method.
What is this technique called?
Anonymous class ???
Is it possible to create a class like this
object of an interface? Hows possible