package cn.intcast2;
import java.util.HashMap;
import java.util.Set;
public class Test2 {
public static void main(String[] args) {
HashMap<String,HashMap<String,Integer>> czbk = new HashMap<String,HashMap<String,Integer>>();
String bj = "北京总部";
HashMap<String,Integer> bjClass = new HashMap<String,Integer>();
bjClass.put("基础班", 6);
bjClass.put("就业班", 7);
bjClass.put("冲刺班", 6);
String sh = "上海分校";
HashMap<String,Integer> shClass = new HashMap<String,Integer>();
shClass.put("基础班", 6);
shClass.put("就业班", 7);
shClass.put("冲刺班", 6);
String gz = "广州分校";
HashMap<String,Integer> gzClass = new HashMap<String,Integer>();
gzClass.put("基础班", 6);
gzClass.put("就业班", 7);
gzClass.put("冲刺班", 6);
czbk.put(bj, bjClass);
czbk.put(sh, shClass);
czbk.put(gz, gzClass);
System.out.println(czbk);
//接下里就是迭代集合czbk
Set<String> outkeys = czbk.keySet();
for (String outkey : outkeys) {
System.out.println("学校地址:"+outkey);
HashMap<String, Integer> outvalue = czbk.get(outkey);
Set<String> inkeys = outvalue.keySet();
for (String inkey : inkeys) {
Integer invalue = outvalue.get(inkey);
System.out.println("班级种类:"+inkey+" 班级个数:"+invalue);
}
System.out.println( );
}
}
}
|