Instantiating anonymous inner classes in Java with additional interface implementation
问题 Let's say I have the following two class/interface definitions: public abstract class FooClass { public abstract void doFoo(); } and public interface BarInterface { public void doBar(); } If I want to make an anonymous inner class that extends/implements both, do I need to do this: public abstract class BothClass extends FooClass implements BarInterface {} ... new BothClass() { public void doFoo() { System.out.println("Fooooooooo!!!!"); } public void doBar() { System.out.println("Baaaaaaaar!!