1.使用 put 方法添加键值对,如果 map 集合中没有该 key 对应的值,则直接添加,并返回 value;如果已经存在对应的值,则会覆盖旧值,value 为新的值,返回值为 value。
2.使用 putIfAbsent 方法添加键值对,如果 map 集合中没有该 key 对应的值,则直接添加,并返回 null,如果已经存在对应的值,则依旧为原来的值,返回值为 value(旧的值)。
/**
* Associates the specified value with the specified key in this map.
* If the map previously contained a mapping for the key, the old
* value is replaced.
*
* @param key key with which the specified value is to be associated
* @param value value to be associated with the specified key
* @return the previous value associated with <tt>key</tt>, or
* <tt>null</tt> if there was no mapping for <tt>key</tt>.
* (A <tt>null</tt> return can also indicate that the map
* previously associated <tt&g