//自定义排序
import java.util.*;
public class test62 {
public static void main(String[] args){
TreeSet tree=new TreeSet();//创建一个采用默认树形自然排序的对象
tree.add(new Integer(50));
tree.add(new Integer(150));
tree.add(new Integer(250));
tree.add(new Integer(450));
tree.add(new Integer(350));
tree.add(new Integer(750));
//获取当前TreeSet的倒序排序器
Iterator it=tree.descendingIterator();
while(it.hasNext()){
System.out.println(((Integer)it.next()).intValue()+' ');
}
}
}
运行结果