猿问
java集合接口map中的put方法返回的是旧值还是新值?什么时候会覆盖旧值?什么时候会返回旧值?
java集合接口map中的put方法返回的是旧值还是新值?什么时候会覆盖旧值?什么时候会返回旧值?
至尊宝的传说
浏览 1331
回答 3
3回答
弑天下
返回旧值,如果没有旧值就返回null。这个操作不管啥条件都会覆盖旧的
0
0
0
PIPIONE
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
0
0
随时随地看视频
慕课网APP
相关分类
Java
我要回答