Can I create an object for Interface?

后端 未结 7 881
庸人自扰
庸人自扰 2020-12-14 21:32

Is it possible to create an object for an interface? If yes, how is it done? According to my view the following code says that we can:



        
相关标签:
7条回答
  • 2020-12-14 22:10

    What you are seeing is an anonymous inner class.

    it’s creating an instance of a new, anonymous,implementer of Runnable class.

    Because an anonymous class definition is an expression, it must be part of a statement.

    0 讨论(0)
提交回复
热议问题