Set接口繼承了Collection接口,Set是不包含重復元素的集合。準確點說,sets中不會包含e1與e2,e1與e2是e1
.equals(e2)的關(guān)系,并且最多包含一個null元素。
public interface Set<E> extends Collection<E> {
// 查詢操作
/**
* 返回集合內(nèi)元素的數(shù)量,最多不會大于Integer.MAX_VALUE
*/
int size();
/**
* 如果不包含元素則會返回true
*/
boolean isEmpty();
/**
* 判斷集合是否包含指定的值
*/
boolean contains(Object o);
/**
* 返回集合中元素的迭代器。不保證元素的順序(除非這個集合提供了這個保證)
*/
Iterator<E> iterator();
/**
* 返回包含集合元素的數(shù)組
*/
Object[] toArray();
/**
*
*/
<T> T[] toArray(T[] a);
// 修改操作
/**
*
*
*/
boolean add(E e);
/**
*
*/
boolean remove(Object o);
// Bulk Operations
/**
*
*/
boolean containsAll(Collection<?> c);
/**
*
*/
boolean addAll(Collection<? extends E> c);
/**
*
*/
boolean retainAll(Collection<?> c);
/**
*
*/
boolean removeAll(Collection<?> c);
/**
*
*/
void clear();
// Comparison and hashing
/**
*
*/
boolean equals(Object o);
/**
*
*/
int hashCode();
/**
* 并行的stream
*/
@Override
default Spliterator<E> spliterator() {
return Spliterators.spliterator(this, Spliterator.DISTINCT);
}
}
沒有注釋的接口可以查看Collection。