Set接口与实现类TreeSet
源码位置
rt.jar/java.util包下
源码类
public class TreeSet<E> extends AbstractSet<E>
implements NavigableSet<E>, Cloneable, java.io.Serializable
特点
对数据有序存储
构造方法
public TreeSet()
public TreeSet(Comparator<? super E> comparator)
public TreeSet(Collection<? extends E> c)
public TreeSet(SortedSet<E> s)
普通方法
public boolean add(E e)
public int size()
public boolean isEmpty()
public boolean contains(Object o)
public boolean remove(Object o)
public void clear()
public Object clone()
public Iterator<E> iterator()
Iterator<String> iter = hashset.iterator();
while(iter.hasNext()) {
System.out.println("元素遍历输出 = " + iter.next());
}
public E first()
public E last()
public SortedSet<E> subSet(E fromElement, E toElement)
public SortedSet<E> headSet(E toElement)
public SortedSet<E> tailSet(E fromElement)
|