Set接口源码解析
无顺序,不包含重复的元素
public interface Set<E> extends Collection<E>
继承了Collection接口的所有方法
接口方法
//显示集合的大小
int size();
//验证集合是否为空
boolean isEmpty();
//验证集合是否包括O元素
boolean contains(Object o);
//遍历的方法
Iterator<E> iterator();
//将集合转化成OBJECT数组
Object[] toArray();
//将集合转化成任意数组
<T> T[] toArray(T[] a);
//添加元素
boolean add(E e);
//移除元素
boolean remove(Object o);
//验证集合中是否包含集合C中所有元素
boolean containsAll(Collection<?> c);
//向集合中添加集合C中所有元素
boolean addAll(Collection<? extends E> c);
//移除不包含集合C中的所有元素
boolean retainAll(Collection<?> c);
//移除集合C中包含的所有元素
boolean removeAll(Collection<?> c);
//移除所有元素
void clear();
//对比方法
boolean equals(Object o);
//生成HASHCODE的方法
int hashCode();
}