今天递交的离职申请,没啥心思啊。。。
上次上花旗面试的时候被问道list排序,果断悲剧了。。。。
----------------------------------------------
首先把comparator接口实现
public class scorecomparator imlements comparator{
public int compara(Object arg0,Object arg1){
Student s1 = (Student)arg0;
Student s2 = (Student)arg1;
if(s1.score > s2.score){
return -1;
}
if(s1.score == s2.score){
return 0;
}
if(s1.score < s2.score){
return 1;
}
}
}
//然后调用
public void comparaTest(List list){
scorecomparator sc = new scorecomparator();
Conlections.sort(list,sc);
}
ps:没实践过,公司笔记本已经被我清理掉了,纯手动运行已经忘了。。。