2 Star 0 Fork 0

20165203Enosh / 20165203xyx

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Example15_8.java 851 Bytes
一键复制 编辑 原始数据 按行查看 历史
20165203Enosh 提交于 2018-04-08 19:28 . week6
mport java.util.*;
class Student implements Comparable {
int english=0;
String name;
Student(int english,String name) {
this.name=name;
this.english=english;
}
public int compareTo(Object b) {
Student st=(Student)b;
return (this.english-st.english);
}
}
public class Example15_8 {
public static void main(String args[]) {
TreeSet<Student> mytree=new TreeSet<Student>();
Student st1,st2,st3,st4;
st1=new Student(90,"赵一");
st2=new Student(66,"钱二");
st3=new Student(86,"孙三");
st4=new Student(76,"李四");
mytree.add(st1);
mytree.add(st2);
mytree.add(st3);
mytree.add(st4);
Iterator<Student> te=mytree.iterator();
while(te.hasNext()) {
Student stu=te.next();
System.out.println(""+stu.name+" "+stu.english);
}
}
}
Java
1
https://gitee.com/xyx-nice/20165203xyx.git
git@gitee.com:xyx-nice/20165203xyx.git
xyx-nice
20165203xyx
20165203xyx
master

搜索帮助