• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Anonymous inner class

 
srinivas sridaragaddi
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15480
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic