## List 集合 ArrayList ## Map集合 HashMap ### 案例 Map集合与List的集合 ``` package com.xiaohu.dao; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class DAO1 { public Map getA() { Map map = new HashMap(); map.put("sid", "XiaoWang"); map.put("s", "XiaoWang"); System.out.println(map.get("sid")); System.out.println(map.size()); return map; } public List> getB(){ List> list = new ArrayList>(); Map map1 = new HashMap(); map1.put("sname","XiaoWang"); map1.put("Sid", "100588"); Map map2 = new HashMap(); map2.put("sname","XiaoZhang"); map2.put("Sid", "100598"); Map map3 = new HashMap(); map3.put("sname","XiaoZhen"); map3.put("Sid", "100518"); list.add(map1); list.add(map2); list.add(map3); for(int i=0;i> it = list.iterator(); // while(it.hasNext()) { // System.out.println(it.next()); // } ``` 最后修改:2024 年 10 月 12 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏