import java.util.*;
public class MapandMap {
public static void main(String[] args) {
HashMap<String,HashMap<String,String>> czbk=new HashMap<String,HashMap<String,String>>();
HashMap<String,String> yure=new HashMap<String,String>();
HashMap<String,String> jiuye=new HashMap<String,String>();
czbk.put("yure",yure);
czbk.put("jiuye", jiuye);
yure.put("01","zhangsan");
yure.put("02","lisi");
jiuye.put("01","wangwu");
jiuye.put("03","zhaoli");
Set<String> keySet=czbk.keySet();
Iterator<String> it=keySet.iterator();
while(it.hasNext()){
String id=it.next();
HashMap<String,String> hm=czbk.get(id);
System.out.println(id);
getStudentInfo(hm);
}
}
public static void getStudentInfo(HashMap<String, String> room) {
// TODO Auto-generated method stub
Set<String> keySet1=room.keySet();
Iterator<String> it1=keySet1.iterator();
while(it1.hasNext())
{
String name=it1.next();
String age=room.get(name);
System.out.println(name+":"+age);
}
}
}
|
|