📄 例7-13.txt
字号:
import java.util.*;
class Student implements Comparable{
int english=0;
String name;
Student(int e,String n){
english=e;name=n;
}
public int compareTo(Object b){
Student st=(Student)b;
return (this.english-st.english);
}
}
public class Example7_13{
public static void main(String args[]){
TreeSet<Student> mytree=new TreeSet<Student>();
Student st1,st2,st3;
st1=new Student(90,"zhan ying");
st2=new Student(66,"wang heng");
st3=new Student(86,"Liuh qing");
mytree.add(st1);
mytree.add(st2);
mytree.add(st3);
Iterator<Student> te=mytree.iterator();
while(te.hasNext()){
Student stu=te.next();
System.out.println(" "+stu.name+" "+stu.english);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -