package cn.itcast_03;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
public class TreeMapTest {
public static void main(String[] args) {
TreeMap<String, Student> tm = new TreeMap<String, Student>();
tm.put("01", new Student("liudehua", 20));
tm.put("02", new Student("chenyixun", 22));
tm.put("03", new Student("zhenzidan", 23));
tm.put("04", new Student("gujuji", 21));
tm.put("05", new Student("chenglong", 26));
tm.put("05", new Student("chenglong", 26));
Set<Map.Entry<String, Student>> set = tm.entrySet();
for (Map.Entry<String, Student> me : set) {
String str = me.getKey();
Student stu = me.getValue();
System.out.println(str + "----" + stu);
}
}
}
|
|