java集合接口map中的put方法返回的是旧值还是新值?什么时候会覆盖旧值?什么时候会返回旧值?
3 回答

PIPIONE
TA贡献1829条经验 获得超9个赞
put返回值的官方描述:
the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)
和上面的答案描述一致
添加回答
举报
0/150
提交
取消