定义:A set is a data structure which does not allow duplicate elements.
Set继承了Collection接口.没有新增方法.
实现要求,如果集合里面已经包含该元素则添加不成功
public boolean add(E object);
实现要求,只添加this集合里面没有的元素,如果参数collection里面有的元素在this集合里面已经有了就不添加此元素,继续下一个,只要有一个元素添加成功就返回true.
public boolean addAll(Collection collection);
网友评论