hashMap 变量

xiaoxiao2022-06-12  40

刚才网上看到 Map<String, String> map = new HashMap<String, String>(); map.put("a", "李荣"); map.put("b", "张明"); map.put("c", "小张"); //方法1:用entrySet() Iterator it=map.entrySet().iterator(); while(it.hasNext()) { Map.Entry<String, String> m=(Map.Entry<String, String>)it.next(); System.out.println("键:"+m.getKey()+" 值:"+m.getValue()); } //方法2:直接在循环中 for(Map.Entry<String, String> m:map.entrySet()) { System.out.println("键:"+m.getKey()+" 值:"+m.getValue()); } 相关资源:敏捷开发V1.0.pptx
转载请注明原文地址: https://www.6miu.com/read-4933671.html

最新回复(0)