wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) 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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Anonymous inner class" Watch "Anonymous inner class" New topic
Author

Anonymous inner class

srinivas sridaragaddi
Ranch Hand

Joined: Jul 24, 2007
Posts: 225


1)i know that an anonymous inner class can extend one subclass
or implement one interface but it cannot do both my questions is
here it is implementing only one interface but even then
the compiler error is generated at line1


SCJP 5.0<br /> <br />"Skills are started with learning and mastered with improvement. Nothing is hereditary except death" BUDDHA...
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

The syntax of this line is just wrong:

You can't add "implements B" at that place. You cannot make an anonymous class implement an interface in that way.

You can create an anonymous class that implements an interface like this:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Anonymous inner class
 
Similar Threads
anonymous classes
Confused about Dan's exam...
Dan's questions
Inner class question from Dan's exam
abstract class instantiation