package com.heima;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class test6 {
public static void main(String[] args) {
HashMap<String, Integer> map = new HashMap<>();
map.put("习~~",60);
map.put("李~~",59);
map.put("胡~~",66);
map.put("温~~",70);
map.put("周~~",73);
Set<Map.Entry<String,Integer>> EntrySet = map.entrySet();
Iterator<Map.Entry<String,Integer>> it = EntrySet.iterator();
while (it.hasNext()) {
Map.Entry<String,Integer> en = it.next();
String key = en.getKey();
Integer value = en.getValue();
System.out.println(key + "=" + value);
}
}
}
|
|