4行遍历Map嵌套集合,感觉自己老牛逼啦...哈哈哈哈哈
[Java] 纯文本查看 复制代码 public class Test {
public static void main(String[] args) {
Map<String, String> javase = new HashMap<String, String>();
javase.put("001", "张三");
javase.put("002", "李四");
Map<String, String> javaee = new HashMap<String, String>();
javaee.put("001", "王五");
javaee.put("002", "赵六");
Map<String,Map<String,String>> czbk = new HashMap<String, Map<String,String>>();
czbk.put("0基础班", javase);
czbk.put("1就业班", javaee);
for(Map.Entry<String, Map<String, String>> entry:czbk.entrySet()){
System.out.println(entry.getKey());
for(Map.Entry<String, String> entry1: entry.getValue().entrySet()){
System.out.println(entry1.getKey()+"..."+entry1.getValue());
}
}
}
}
一般Map嵌套集合遍历,没有10多行根本遍历不出来...浓缩为4行..厉害吧.....
|