java中把3个学生装入2个map 再把2个map装入list 怎么遍历
2个回答
展开全部
ArrayList<HashMap<Integer,Student>> list =new ArrayList<HashMap<Integer,Student>>();
HashMap<Integer,Student> map1=new HashMap<Integer,Student>();
HashMap<Integer,Student> map2=new HashMap<Integer,Student>();
map1.put(1,new Student());
map1.put(2,new Student());
map2.put(3,new Student());
list.add(map1);
list.add(map2);
for(HashMap<Integer,Student> map:list){
Set<Integer> set=map.keySet();
for(Integer in:set){
Student stu=map.get(in);
System.out.println(stu.toString());
}
}
HashMap<Integer,Student> map1=new HashMap<Integer,Student>();
HashMap<Integer,Student> map2=new HashMap<Integer,Student>();
map1.put(1,new Student());
map1.put(2,new Student());
map2.put(3,new Student());
list.add(map1);
list.add(map2);
for(HashMap<Integer,Student> map:list){
Set<Integer> set=map.keySet();
for(Integer in:set){
Student stu=map.get(in);
System.out.println(stu.toString());
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询