ArrayList.add(index, element)失败,都是size的误解

  在使用ArrayList时遇到一个很愚蠢的问题,想在大小为10的ArrayList的第5个位置插入10,结果抛异常。代码示例以下java ArrayList<Integer> arr=new ArrayList<Integer>(10); arr.add(5, 10); 异常为数组 Exception in thread "main" java.lang.IndexOutOfBoundsExc
相关文章
相关标签/搜索