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;
}
}
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;
}
}