为什么Java中的许多Collection类都扩展抽象类并实现接口? [英] Why do many Collection classes in Java extend the abstract class and implement the interface as well?
本文介绍了为什么Java中的许多Collection类都扩展抽象类并实现接口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么Java中的许多Collection类都扩展抽象类并实现接口(也是通过给定的抽象类实现的)?
Why do many Collection classes in Java extend the Abstract class and also implement the interface (which is also implemented by the given abstract class)?
HashSet
扩展 AbstractSet
并实现 Set
,但 AbstractSet
已实现设置
。
For example, class HashSet
extends AbstractSet
and also implements Set
, but AbstractSet
already implements Set
.
推荐答案
这是一种记住这个类真正实现了该接口的方式。
它不会有任何坏的效果,它可以帮助理解代码,而不必通过给定类的完整层次结构。
It's a way to remember that this class really implements that interface.
It won't have any bad effect and it can help to understand the code without going through the complete hierarchy of the given class.
这篇关于为什么Java中的许多Collection类都扩展抽象类并实现接口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文