Method 1:
private void enlarge (final int size) {
byte[] newData = new byte[Math.max(2*data.length, length + size)];
System.arraycopy(data, 0, newData, 0, length);
data = newData;
}
enlarge an array
最新推荐文章于 2024-09-19 09:48:11 发布
本文介绍了一种数组扩容的方法,通过创建一个更大容量的新数组,并将原有数组的数据复制到新数组中来实现。这种方法常用于动态调整数据结构的大小。
2651

被折叠的 条评论
为什么被折叠?



