本帖最后由 极限冰风 于 2013-4-29 10:58 编辑
import java.util.Comparator;
public class student {
public String name;//姓名
public int score;//分数
public student(String name,int score){
this.name=name;
this.score=score;
}
}
//按照实现Comparator接口的排序方法
//按学生的分数从高到低排序?
public class Tes<student> implements Comparator<student> {
@Override
public int compare(student o1, student o2) {
//student的对象为什调用不了里面的变量?
int num=new Integer(o1.score).compareTo(o1.score);
return 0;
}
} |