当我使用 .putAll()
时,另一个 .putAll()
会覆盖 map 的内容吗?
我的 map 会包含 SomeOfMyObjects 和 SomeOfMyObjects 吗?
Map<MyObject> blah = new HashMap<>();
blah.putAll('SomeOfMyObjects')
blah.putAll('SomeOfMyObjects')
谢谢!
最佳答案
Copies all of the mappings from the specified map to this map (optional operation). The effect of this call is equivalent to that of calling put(k, v) on this map once for each mapping from key k to value v in the specified map.
this call is equivalent to that of calling put(k, v)
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 m.containsKey(k) would return true.)
关于java - Map putAll 覆盖还是添加?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17827573/