File tree Expand file tree Collapse file tree 1 file changed +1
-1
lines changed
Expand file tree Collapse file tree 1 file changed +1
-1
lines changed Original file line number Diff line number Diff line change @@ -729,7 +729,7 @@ private void grow(int minCapacity) {
729729** 我们再来通过例子探究一下`grow()` 方法:**
730730
731731- 当 `add` 第 1 个元素时,`oldCapacity` 为 0 ,经比较后第一个 if 判断成立,`newCapacity = minCapacity`(为 10 )。但是第二个 if 判断不会成立,即 `newCapacity` 不比 `MAX_ARRAY_SIZE ` 大,则不会进入 `hugeCapacity` 方法。数组容量为 10 ,`add` 方法中 return true ,size 增为 1 。
732- - 当 `add` 第 11 个元素进入 `grow` 方法时,`newCapacity` 为 15 ,比 `minCapacity`(为 11 )大,第一个 if 判断不成立。新容量没有大于数组最大 size,不会进入 huge` C `apacity 方法。数组容量扩为 15 ,add 方法中 return true ,size 增为 11 。
732+ - 当 `add` 第 11 个元素进入 `grow` 方法时,`newCapacity` 为 15 ,比 `minCapacity`(为 11 )大,第一个 if 判断不成立。新容量没有大于数组最大 size,不会进入 `hugeCapacity` 方法。数组容量扩为 15 ,add 方法中 return true ,size 增为 11 。
733733- 以此类推······
734734
735735** 这里补充一点比较重要,但是容易被忽视掉的知识点:**
You can’t perform that action at this time.
0 commit comments