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
相關文章
相關標籤/搜索