package MapDemo;
import java.util.Comparator;
public class StudentNameCompare implements Comparator<Student>{
public int compare(Student s1,Student s2)
{
int num = s1.getName().compareTo(s2.getName());
if(num==0)
return num = new Integer(s1.getAge()).compareTo(new Integer(s2.getAge()));
return num;
}
}
|
|