}
//定义一个比较器,以姓名长度为主要比较
class LenCompare implements Comparator<Student>
{
public int compare(Student s1,Student s2)
{
int num=new Integer(s1.getName().length()).compareTo(new Integer(s2.getName().length()));
if (num==0)
{
return new Integer(s1.getAge()).compareTo(s2.getAge());
}
return num;
}
}