- package cn.text;
- import java.util.*;
- class Foo
- {
- public static void main(String[] args)
- {
- TreeMap<String,TreeMap<String,String>>tm=new TreeMap<String,TreeMap<String,String>>();
- TreeMap<String,String>tm1=new TreeMap<String,String>();
- TreeMap<String,String>tm2=new TreeMap<String,String>();
- tm.put("yure",tm1);
- tm.put("jiuye",tm2);
- tm1.put("01","zahgnsan");
- tm1.put("02","lisi");
- tm2.put("01","wangwu");
- tm2.put("02","zhaoliu");
- getStudentInfo(tm,"yure");
- }
- public static void getStudentInfo(TreeMap tm,String room)
- {
- TreeMap<String,String>tm1=(TreeMap<String, String>) tm.get(room);
- Set<String>keySet=tm1.keySet();
- Iterator<String>it=keySet.iterator();
- while(it.hasNext())
- {
- String s=it.next();
- System.out.println(s+".."+tm1.get(s));
- }
- }
- }
复制代码 |