设为首页 加入收藏

TOP

Map大家族的那点事儿(2) :AbstractMap(三)
2018-09-04 20:46:40 】 浏览:306
Tags:Map 大家族 那点 事儿 AbstractMap
lue) { this.key = key; this.value = value; } public SimpleImmutableEntry(Entry<? extends K, ? extends V> entry) { this.key = entry.getKey(); this.value = entry.getValue(); } public K getKey() { return key; } public V getValue() { return value; } public V setValue(V value) { throw new UnsupportedOperationException(); } public boolean equals(Object o) { if (!(o instanceof Map.Entry)) return false; Map.Entry<?,?> e = (Map.Entry<?,?>)o; return eq(key, e.getKey()) && eq(value, e.getValue()); } public int hashCode() { return (key == null ? 0 : key.hashCode()) ^ (value == null ? 0 : value.hashCode()); } public String toString() { return key + "=" + value; } }

我们通过阅读上述的源码不难发现,AbstractMap实现的操作都依赖于entrySet()所返回的集合视图。剩下的函数就没什么好说的了,有兴趣的话可以自己去看看。

首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇做一次面向对象的体操:将JSON字.. 下一篇一次Java内存泄漏调试的有趣经历

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目