import java.util.*;public class Example04 implements Comparable {
String name;
long id;
public Example04(String name,long id) {
this.id=id;
this.name=name;
}
public int compareTo(Object o) {
Example04 upsu=(Example04)o;
int result=id>upsu.id?1:(id==upsu.id?0:1);
return result;
}
public long getid() {
return id;
}
public void setid(long id) {
this.id=id;
}
   public void setname(String name) {
this.name=name;
}
   public String getname() {
   return name;
}
   public static void main(String[] args) {
Example04 stu1=new Example04("李同学", 01011);
Example04 stu2=new Example04("张同学", 01023);
Example04 stu3=new Example04("望同学", 02011);
Example04 stu4=new Example04("嘛同学", 12345);
Example04 stu5=new Example04("六同学", 01411);
Example04 stu6=new Example04("吗同学", 51011);
TreeSet tree=new TreeSet();
tree.add(stu1);
tree.add(stu2);
tree.add(stu3);
tree.add(stu4);
tree.add(stu5);
tree.add(stu6);

Iterator it=tree.iterator();

System.out.println("tree中的所有元素:");
while(it.hasNext()){
Example04 stu=(Example04)it.next();
System.out.println(stu.getid()+"  "+stu.getname());
}

it=tree.headSet(stu2).iterator();
System.out.println("截取前面部分的集合:");
while(it.hasNext()){
Example04 stu=(Example04)it.next();
System.out.println(stu.getid()+"   "+stu.getname());
}

it=tree.subSet(stu2, stu3).iterator();
System.out.println("截取中间的元素内容:");
while(it.hasNext()){
Example04 stu=(Example04)it.next();
System.out.println(stu.getid()+"    "+stu.getname());
}

}
}
为什么无法正常运行 抛出 java.lang.IllegalArgumentException: fromKey > toKey