本帖最后由 ò壞尛孩 于 2014-4-23 23:44 编辑
- import java.util.*;
- class MapDemo3
- {
- public static void main(String[] args)
- {
- HashMap <String,HashMap<String,String>> heima=new HashMap<String,HashMap<String,String>>();
- HashMap<String,String> classAndroid=new HashMap<String,String>();
- HashMap<String,String> classCloudComputing=new HashMap<String,String>();
- heima.put("安卓班",classAndroid);
- heima.put("云计算班",classCloudComputing);
-
- classAndroid.put("001","zhangsan");
- classAndroid.put("002","lisi");
-
- classCloudComputing.put("001","wangwu");
- classCloudComputing.put("002","zhaoliu");
- getStudentInfo(classAndroid);
- getStudentInfo(classCloudComputing);
- getStudentInfo1(heima);
- }
- public static void getStudentInfo(HashMap<String,String> roomMap)
- {
- Iterator<String> it =roomMap.keySet().iterator();
- while(it.hasNext())
- {
- String id=it.next();
- String name=roomMap.get(id);
- System.out.println(id+":"+name);
- }
- }
- public static void getStudentInfo1(HashMap <String,HashMap<String,String>> roomMap)
- {
- Iterator<String> it=roomMap.keySet().iterator();
- while(it.hasNext())
- {
- String roomname=it.next();
- HashMap<String,String> room=roomMap.get(roomname);
- System.out.println(roomname);
- getStudentInfo(room);
- }
- }
- }
复制代码
|
|