Collection.remove()的奇怪签名

时间:2011-07-20 13:15:30

标签: java generics collections

  

可能重复:
  Why aren't Java Collections remove methods generic?

为什么Collection.remove()的签名定义如下:

public boolean remove(Object o)

而不是

public boolean remove(E e)

其中E是集合的类型。

我们知道如果cCollection类型E [Collection<E>]的c,那么E将始终包含E或子对象类E。那么为什么我们不将方法参数限制为? extends E或{{1}}

0 个答案:

没有答案