将单个元素添加到ArrayList会添加另外11个null元素吗?

dig*_*tie 0 java arrays null android arraylist

我正在填充一个ArrayList'pps'的Points.

对我而言,这似乎非常简单,但在此运行之后,arraylist中有null元素.

for(int i =0; i< currentt.getPointCount();i++){
   File pXml = new File(tourFolderPath + "point_" + (i+1) +".xml");
   if (pXml.exists()){
      pt = (Point)MXP.createObject(pXml, 2);
   }
   pts.add(pt);
}
Run Code Online (Sandbox Code Playgroud)

在调试器中检查后,似乎第一次出现"pts.add(pt);"行.运行它添加一个合法的点元素.但是,它还添加了10个其他null元素.

有任何想法吗?

mre*_*mre 6

一个ArrayList包含10的初始容量.