//treeset排序集合 import java . util . * ; public class test61 { public static void main ( String [] args ){ TreeSet tree = new TreeSet (); //创建一个采用默认树形自然排序的对象 tree . add ( new Integer ( 50 )); tree . a
import java.util.*;
public class test61{
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));
for(Object o:tree){
System.out.println(Integer.parseInt(o.toString()));
}
}
}
运行结果