好吧,你在这个程序的基础上做修改,使它按学生的姓名“倒序"排序:这个它的结果是:
jiuyeban
lisi001---001
lisi002---002
lisi003---003
lisi004---004
lisi005---005
yureban
zhangsan01---01
zhangsan02---02
zhangsan03---03
zhangsan04---04
zhangsan05---05
- public static void NormalMathod_TreeMap()
- {
- TreeMap<String,TreeMap<String,String>> czbk=new TreeMap<String,TreeMap<String,String>>();
- TreeMap<String,String> yure=new TreeMap<String,String>();
- TreeMap<String,String> jiuye=new TreeMap<String,String>();
-
- czbk.put("yureban",yure);
- czbk.put("jiuyeban",jiuye);
-
- yure.put("zhangsan01","01");
- yure.put("zhangsan02","02");
- yure.put("zhangsan04","04");
- yure.put("zhangsan05","05");
- yure.put("zhangsan03","03");
-
- jiuye.put("lisi001","001");
- jiuye.put("lisi004","004");
- jiuye.put("lisi002","002");
- jiuye.put("lisi005","005");
- jiuye.put("lisi003","003");
-
- Set<Map.Entry<String,TreeMap<String,String>>>gs_entry=czbk.entrySet();
- for(Iterator<Map.Entry<String,TreeMap<String,String>>> it=gs_entry.iterator() ;it.hasNext();)
- {
- Map.Entry<String,TreeMap<String,String>> me=it.next();
- String roomName=me.getKey();
- TreeMap<String,String> room=me.getValue();
- System.out.println(roomName);
- getinfos_Entry(room);
- }
- }
复制代码
|