对JDK源码的疑惑(也是对接口的疑惑)
kewin 2004-10-19 10:21:08 最近在看JDK collection 的源码,看到
Set extends Collection 时重复写了全部的接口。这是为什么?
附代码片断:
public interface Set extends Collection {
// Query Operations
/**
* Returns the number of elements in this set (its cardinality). If this
* set contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
* <tt>Integer.MAX_VALUE</tt>.
*
* @return the number of elements in this set (its cardinality).
*/
int size();
/**
* Returns <tt>true</tt> if this set contains no elements.
*
* @return <tt>true</tt> if this set contains no elements.
*/
boolean isEmpty();
/**
* Returns <tt>true</tt> if this set contains the specified element. More
* formally, returns <tt>true</tt> if and only if this set contains an
* element <code>e</code> such that <code>(o==null ? e==null :
* o.equals(e))</code>.
*
* @param o element whose presence in this set is to be tested.
* @return <tt>true</tt> if this set contains the specified element.
* @throws ClassCastException if the type of the specified element
* is incompatible with this set (optional).
* @throws NullPointerException if the specified element is null and this
* set does not support null elements (optional).
*/
boolean contains(Object o);
.....................................