Map map = new HashMap(){}; map.put("a", "A"); map.put("b", "B"); map.put("c", "C"); //第一种 Set set = map.keySet(); Iterator it = set.iterator(); while(it.hasNext()){ String str = it.next().toString(); } //第二种 Set<Entry> entryset = map.entrySet(); Iterator iter = entryset.iterator(); while(iter.hasNext()){ Entry entry = (Entry)iter.next(); } //第三种 for(Entry entry : map.entrySet()){ String strkey = entry.getKey(); String strval = entry.getValue(); }
java Map 遍历
最新推荐文章于 2024-05-29 11:26:00 发布