jdk1.8
使用putAll时,新map中的值仅为旧map值所对应对象的引用,并不会产生新对象。
如下,使用for循环赋值!
public void putAll(Map<? extends K, ? extends V> m) {
putMapEntries(m, true);
}
final void putMapEntries(Map<? extends K, ? extends V> m, boolean evict) {
int s = m.size();
if (s > 0) {
....
....
for (Map.Entry<? extends K, ? extends V> e : m.entrySet()) {
K key = e.getKey();
V value = e.getValue();
putVal(hash(key), key, value, false, evict);
}
}
}
继续阅读与本文标签相同的文章
-
无需开发,IT事件接入钉钉的方法详解
2026-05-19栏目: 教程
-
make: [packet.o] Error 127
2026-05-19栏目: 教程
-
文档小喇叭 | 支付宝小程序开发常见问题 FAQ
2026-05-19栏目: 教程
-
定时器Cron配置方法
2026-05-19栏目: 教程
-
你有一个阿里云十周年大礼包待领取
2026-05-19栏目: 教程
