⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠ You can decompress Drawing data with the command palette: ‘Decompress current Excalidraw file’. For more info check in plugin settings under ‘Saving’
Excalidraw Data
Text Elements
0
1
2
0
1
2
3
假设初始capacity=3
newArray
array
11
22
33
11
22
33
if(capacity == size) {
int newCapacity = capacity + (capacity >> 1); //扩容规则就按照原本容量的1.5倍来吧
Object[] newArray = new Object[newCapacity]; //创建一个新的数组来存放更多的元素
System.arraycopy(array, 0, newArray, 0, size); //使用arraycopy快速拷贝原数组内容到新的数组
array = newArray; //更换为新的数组
capacity = newCapacity; //容量变成扩容之后的
}
array