Anonymous class with interface

后端 未结 4 1895
挽巷
挽巷 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:16

    It allows you to create a new anonymous class that implements ActionListener because you're providing the implementation, you're just not giving it a class name.

提交回复
热议问题