File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "anonymous classes" Watch "anonymous classes" New topic

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

Joined: Oct 13, 2005
Posts: 46349
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.
I agree. Here's the link:
subject: anonymous classes
It's not a secret anymore!