三种map的循环

时间:2021-07-14 00:14:32
for(Map.Entry<String, List> entry : map.entrySet()) {
System.out.println(entry.getKey());
List ls=entry.getValue();
} Iterator it = map.keySet().iterator();
while(it.hasNext()){
String key = (String) it.next();
List value = map.get(key);
} Map m = new HashMap();
m.put("name", "LQX");
m.put("age", 23);
m.put("sex", true);
Object s[] = m.keySet().toArray();
for(int i = 0; i < m.size(); i++) {
System.out.println(m.get(s[i]));
}