import java.util.TreeSet;
class treeset{
public static void main(String[] args){
TreeSet ts=new TreeSet();
stud s1=new stud("张三");
stud s2=new stud("李四");
ts.add(s1);
ts.add(s2);
System.out.println(ts);
}
}
class stud implements Comparable{
private String name;
public stud(String name){
this.name=name;
}
public int compareTo(Object o){
stud s=(stud)o;
int i=name.compareTo(s.name);
return i;
}
public String toString(){
return name;
}
}
posted on 2005-09-20 17:29
千山鸟飞绝 阅读(447)
评论(0) 编辑 收藏 所属分类:
J2SE