Iterator接口中声明了如下方法:
hasNext();判断集合中的元素是否遍历完etc while(iterator.hasNext());
next(); 返回下一个元素;
remove();从集合中删除上一个由next()方法返回的元素
使用自然排序的时候只能向TreeSet集合中加入同类型的对象,并且这些对象必须实现了Comparable接口etc. public class Customer implements Comparable{
Public int comparaTo(Object obj){
}
}
除了自然排序,还可以使用客户化排序:etc public class CustomerComparator implements Comparator<Customer>{
Public int compare(Customer a, Customer b){
}
}
Set<Customer