This commit is contained in:
krahets
2023-02-07 17:17:14 +08:00
parent ecbf2d1560
commit 1ca5c731f7
19 changed files with 501 additions and 192 deletions

View File

@@ -801,6 +801,17 @@ comments: true
// 更新列表容量
capacity = nums.length;
}
/* 将列表转换为数组 */
public int[] toArray() {
int size = size();
// 仅转换有效长度范围内的列表元素
int[] nums = new int[size];
for (int i = 0; i < size; i++) {
nums[i] = get(i);
}
return nums;
}
}
```