Anonymous class with interface

后端 未结 4 1894
挽巷
挽巷 2021-01-16 14:24

I am confused about the concept of interface when dealing with anonymous inner class. As far as I know that you can\'t instantiate an interface in Java, so the following sta

4条回答
  •  太阳男子
    2021-01-16 15:23

    When you create an inner-class, you are instantiating an anonymous class that implements the interface.

    In your case, The effect is the same of: public class Foo implements ActionListener

提交回复
热议问题