import java.util.Iterator;import java.util.Set;import java.util.TreeSet;public class Student1 { String id,name,birthday; int age; public Student1(String id1,String name1,String birthday1,int age1){ id=id1; name=name1; birthday=birthday1; age=age1; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getBirthday() { return birthday; } public void setBirthday(String birthday) { this.birthday = birthday; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public static void main(String[] args){ Set<Student1>stu=new TreeSet<>(); stu.add(new Student1("001","张珊","1998-05-06", 18)); stu.add(new Student1("002","张明","1994-10-16", 21)); stu.add(new Student1("003","李四","1995-03-04", 20)); stu.add(new Student1("009","钱江","1993-10-10", 22)); stu.add(new Student1("006","小红","1996-12-11", 19)); stu.add(new Student1("005","小明","1995-11-14", 20)); Iterator<Student1>student=stu.iterator(); while(student.hasNext()){ Student1 stu1=student.next(); System.out.println(stu1); } }}
添加回答
举报
0/150
提交
取消