Map的put

Attention:如果当前key已存在,则会覆盖key在Map当中原来的值。

源码解释展示;

/**
 * Associates the specified value with the specified key in this map
 * (optional operation).  If the map previously contained a mapping for
 * the key, the old value is replaced by the specified value.  (A map
 * m is said to contain a mapping for a key k if and only
 * if {@link #containsKey(Object) m.containsKey(k)} would return
 * true.)

你可能感兴趣的:(Java)