java.util.ArrayList.grow()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(1.1k)|赞(0)|评价(0)|浏览(287)

本文整理了Java中java.util.ArrayList.grow()方法的一些代码示例,展示了ArrayList.grow()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ArrayList.grow()方法的具体详情如下:
包路径:java.util.ArrayList
类名称:ArrayList
方法名:grow

ArrayList.grow介绍

[英]Increases the capacity to ensure that it can hold at least the number of elements specified by the minimum capacity argument.
[中]增加容量,以确保它至少可以容纳最小容量参数指定的元素数。

代码示例

代码示例来源:origin: org.apidesign.bck2brwsr/emul

private void ensureCapacityInternal(int minCapacity) {
  modCount++;
  // overflow-conscious code
  if (minCapacity - elementData.length > 0)
    grow(minCapacity);
}

代码示例来源:origin: jtulach/bck2brwsr

private void ensureCapacityInternal(int minCapacity) {
  modCount++;
  // overflow-conscious code
  if (minCapacity - elementData.length > 0)
    grow(minCapacity);
}

代码示例来源:origin: stackoverflow.com

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
  at java.util.Arrays.copyOf(Arrays.java:2245)
  at java.util.Arrays.copyOf(Arrays.java:2219)
  at java.util.ArrayList.grow(ArrayList.java:213)
  at java.util.ArrayList.ensureCapacityInternal(ArrayList.java:187)
  at java.util.ArrayList.add(ArrayList.java:411)
  at test.Test.main(OOME.java:26)
Java Result: 1

相关文章