An anonymous inner class can extend one subclass or implement one
interface. Unlike non-anonymous classes (inner or otherwise), an anonymous
inner class cannot do both. In other words, it cannot both extend a class and
implement an interface, nor can it implement more than one interface.
Chapter 8 p.658 K&B SCJP for Java 5
Harry Henriques wrote:Thanks for your reply, Sebastian. But the code below compiles and runs just fine. I instantiate an implementation of interface Range and an implementation of interface Grassland. The output is below in red.
The extended class can implement lots of interfaces itself, or implemented interface can extend from lots of other interfaces. Just like it shows in your code.
Ninad Kulkarni wrote:As per my knowledge anonymous inner class implement only one interface.