package heima0803.day17.treesetbao;
import java.util.TreeSet;
public class TreeSetDemo {
public static void main(String[] args) {
TreeSet<Student> ts = new TreeSet<Student>();
ts.add(new Student("aaaaa", 18));
ts.add(new Student("ssssss", 22));
ts.add(new Student("ddddddd", 38));
ts.add(new Student("fffffffff", 37));
ts.add(new Student("ggggg", 28));
ts.add(new Student("ggdddggg", 12));
ts.add(new Student("hhhgrhh", 35));
ts.add(new Student("jjdjjj", 10));
ts.add(new Student("dddgwfsafdd", 38));
for (Student s : ts) {
System.out.println(s.getName() + "***" + s.getAge());
}
}
}
|
|