我不确定这种方法是如何工作的。我的理解是我们创建了一个临时数组,其大小是theItems.length(theItems 是另一个数组)的两倍。之后,我们将项目复制到临时数组,最后我们写 theItems = temp; (我不确定为什么以及会发生什么)(这是否意味着 theItems 的大小也翻了一番?)。我们不能在不使用 temp 的情况下将 theItems 的大小加倍吗?
private void resize() {
String[] temp = new String[theItems.length*2];
for (int i=0 ; i < noOfItems ; i++){
temp[i]=theItems[i];
}
theItems=temp;
}
人到中年有点甜
尚方宝剑之说
手掌心
慕莱坞森
随时随地看视频慕课网APP
相关分类