public static void main(String[] args) {
HashMap<Integer, String> map = new HashMap<>();
//向map中插入数据
map.put(1, "sss");
map.put(2, "aaa");
map.put(3, "ccc");
//修改key=1的value为ddd
String a = map.put(1, "ddd");
System.out.println(map);
System.out.println(a);
}
It can be seen that the value value of key=1 in the map has become ddd, and the old value value sss is returned