为什么在以下代码中必须实现Comparable接口才能用Comparator接口进行排序?
Comparable接口和Comparator接口有什么关系吗?
import java.util.*;
class TreeSetTest
{
public static void main(String[] args)
{
TreeSet<Object> ts=new TreeSet<Object>();
ts.add(new MyStudents(2,"Vida"));
ts.add(new MyStudents(4,"Lillian"));
ts.add(new MyStudents(1,"Chaner"));
ts.add(new MyStudents(2,"Vida"));
Iterator it=ts.iterator();
while(it.hasNext())
{
System.out.println(it.next());
}

}

}class MyStudents implements Comparable<Object>
{
int number;
String name;
MyStudents(int number,String name)
{
this.number=number;
this.name=name;
}
public String toString()
{
return "The Student's information is: Number="+number+" name="+name;
}
public int compareTo(Object o)
{
MyStudents mst=(MyStudents)o;
return number > mst.number ? 1 : (number==mst.number ? 0 : -1);
}
class MyStudentsComparator implements Comparator<Object>
{
public int compare(Object o1,Object o2)
{
MyStudents mst1=(MyStudents)o1;
MyStudents mst2=(MyStudents)o2;
int result=mst1.number>mst2.number?1:(mst1.number==mst2.number?0:-1);
if(result==0)
{
return mst1.name.compareTo(mst2.name);
}
return result;

}
}

}