[Java] 纯文本查看 复制代码
public class Demo {
public static void main(String[] args) {
Map<String,Integer>m= new HashMap<>();
m.put("赵丽颖",168);
m.put("刘亦菲",165);
m.put("杨幂",160);
m.put("刘亦菲",150);
System.out.println(m);
Set<String> s = m.keySet();
/* Iterator<String> it = s.iterator();
while (it.hasNext()){
String key = it.next();
Integer value = m.get(key);
System.out.println(key+"="+value);
System.out.println("=================");*/
for (String s1 : s) {
Integer v = m.get(s1);
System.out.println(s1+"="+v);
}
System.out.println("===========");
Set<Map.Entry<String, Integer>> set = m.entrySet();
Iterator<Map.Entry<String, Integer>> it = set.iterator();
while(it.hasNext()){
Map.Entry<String, Integer> en = it.next();
System.out.println(en.getKey()+"="+en.getValue());
}
}
}