摘要: HashMap的底层实现是一个Node类型的数组,也就是说使用put(key, value)方法的时候就把key和value根据hashcode值存在table数组相应的下标中,源码如下: Node是一个实现了Map.Entry的泛型类,源码如下: 2 HashMap的构造函数 HashMap共有四 阅读全文
posted @ 2019-07-23 10:40 SundayMoning 阅读(201) 评论(0) 推荐(0) 编辑
摘要: tableSizeFor(int cap)方法返回不小于指定参数cap的最小2的整数次幂,具体是怎么实现的呢?看源码! /** * Returns a power of two size for the given target capacity. */ static final int table 阅读全文
posted @ 2019-07-23 10:27 SundayMoning 阅读(659) 评论(0) 推荐(0) 编辑