创建一个HasMap对象,并在其中添加一些员工的姓名和工资:张三,8000,李四,6000.然后从HashMap对象中获取这两个人的薪水并打印出来,接着把张三的工资改为85000,再把他们的薪水显示出
package com.dh.ch07;
import java.util.*;
public class HashMapTest {
public static void main(String[] args) {
HashMap<String,Integer>hashMap = new HashMap<String,Integer>();
hashMap.put("zhangsan",8008);
hashMap.put("lisi",6000);
Set<Map.Entry<String, Integer>> set = hashMap.entrySet();
for(Map.Entry<String,Integer>entry:set) {
System.out.println(entry.getKey()+":"+entry.getValue());
}
System.out.println("Modify....................");
hashMap.put("zhangsan", 8500);
for(Map.Entry<String,Integer>entry1:set) {
System.out.println(entry1.getKey()+":"+entry1.getValue());
}
}
}