为什么在Collection中声明的方法在List Interface中也重复? [英] Why methods declared in Collection are duplicated in List Interface also?

查看:60
本文介绍了为什么在Collection中声明的方法在List Interface中也重复?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何特定原因(除了下面提到的原因),为什么java.util.Collection中声明的所有方法都在java.util.List接口中重复?

Is there any specific reason(other than what is mentioned below) why all the methods declared in java.util.Collection is duplicated in java.util.List interface?

根据java.util.List Api:

According to java.util.List Api:

除了在Collection接口中指定的规定之外,List接口还对迭代器,add,remove,equals和hashCode方法的协定附加了其他规定.为了方便起见,还包括其他继承方法的声明.

The List interface places additional stipulations, beyond those specified in the Collection interface, on the contracts of the iterator, add, remove, equals, and hashCode methods. Declarations for other inherited methods are also included here for convenience.

仅出于附加文档(规定)的目的,重复这样的方法声明会很好吗?

Just for the sake of addtional documentation(stipulations) is it good to repeat the method declarations like that?

推荐答案

仅出于附加文档(规定)的目的,重复这样的方法声明会很好吗?

Just for the sake of addtional documentation(stipulations) is it good to repeat the method declarations like that?

您将如何做不同的事情?不利之处是什么?

How would you do it differently? What is the downside?

是的,这确实是最简单的方法.

Yes, this really is the simplest way to do that.

这篇关于为什么在Collection中声明的方法在List Interface中也重复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆