Originally posted by Michael Carlson:
So marc, your saying the anonymous sub class of A is not implementing the interface, therefore the super class must implement the interface, and the anonymous class extends the super class. In your example your using an implementer of the interface, rather than a subclass of the class.
Thanks
Right. An anonymous class
either extends a class (without using "extends")
or implements a single interface (without using "implements")...
ClassOrInterface x = new ClassOrInterface() { //anonymous body };
The reference is
automatically upcast to the type of the extended class or the implemented interface. This is why you can only override or implement methods that are already declared in the superclass or interface. Any new methods you add to the anonymous body won't be accessible after the upcast.
[ February 06, 2006: Message edited by: marc weber ]