This question already has answers here:
Why do many Collection classes in Java extend the abstract class and implement the interface as well?
(10个答案)
5年前关闭。
为什么HashMap扩展AbstractMap并实现Map?扩展AbstractMap是不够的,因为AbstractMap实现了Map?
(10个答案)
5年前关闭。
为什么HashMap扩展AbstractMap并实现Map?扩展AbstractMap是不够的,因为AbstractMap实现了Map?
最佳答案
这是多余的。我怀疑这样做是出于“文档”的原因。 HashMap实现Map,您可以依靠它。它扩展AbstractMap的事实可以说只是一个实现细节。 (尽管将来的HashMap版本不会扩展AbstractMap的可能性极小,因为那里可能有一些代码希望将HashMap分配给AbstractMap。)
关于Java.util.HashMap-为什么HashMap扩展AbstractMap并实现Map?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2294519/
10-10 18:11