问题描述
Java中的以下关键字有什么区别: implements
, extends
?
What's the difference between the following keywords in Java: implements
, extends
?
推荐答案
接口
是类$的抽象规范c $ c>应该表现为
类
是这种规范的具体实现。
An interface
is an abstract specification of how a class
should behave whilst a class
is a concrete implementation of such a specification.
因此,当你写 implements
你说你正在实现你编写的实现中的一些抽象规范。
Therefore, when you write implements
you're saying that you are fulfilling some abstract specification in the implementation you've written.
extends
表示您采用实现( class
)或规范( interface $ c) $ c>)并添加不同的或新的功能(或更改其行为的规范),从而修改其行为并扩展 - 它。
extends
means that you take either an implementation (class
) or specification (interface
) and add to it with different or new functionality (or change the specification of its behaviour), thus modifying its behaviour and extend-ing it.
这篇关于工具和工具之间有什么区别?在Java中扩展关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!