Implements vs extends: When to use? What's the difference?

前端 未结 18 594
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 17:03

Please explain in an easy to understand language or a link to some article.

18条回答
  •  伪装坚强ぢ
    2020-11-22 17:27

    A class can only "implement" an interface. A class only "extends" a class. Likewise, an interface can extend another interface.

    A class can only extend one other class. A class can implement several interfaces.

    If instead you are more interested in knowing when to use abstract classes and interfaces, refer to this thread: Interface vs Abstract Class (general OO)

提交回复
热议问题