- 博客(3)
- 收藏
- 关注
转载 JDK1.8_HashMap源码__构造函数
HashMap的底层实现是一个Node类型的数组,也就是说使用put(key, value)方法的时候就把key和value根据hashcode值存在table数组相应的下标中,源码如下: /** * The table, initialized on first use, and resized as * necessary. When alloc...
2019-07-23 10:40:00
137
转载 JDK1.8_HashMap源码__tableSizeFor方法解析
tableSizeFor(int cap)方法返回不小于指定参数cap的最小2的整数次幂,具体是怎么实现的呢?看源码! /** * Returns a power of two size for the given target capacity. */ static final int tableSizeFor(int cap) { ...
2019-07-23 10:27:00
197
转载 JDK1.8_HashMap源码之resize
final Node<K,V>[] resize() { //创建一个Node数组用于存放table中的元素, Node<K,V>[] oldTab = table; //获取旧table的长度 int oldCap = (oldTab == null) ? 0 : oldTab....
2019-07-16 08:38:00
79
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人