Iterator 迭代器越界
例子如下:
Iterator i = set.iterator(); while (i.hasNext()) { System.out.println(i.next()); pw.println(i.next()); }
while(iter.hasNext()) { ArrayList<SprintUserStory> undoneUserStoriesList = SprintUtil.getUndoneUserStoriesList(iter.next().getID(),iter.next().getPkey()); if(undoneUserStoriesList.size() >0){ willdonefeautre--; }
上述错误均是因为两次.next造成的。可修改为
while (i.hasNext()) { String ss = (String) i.next(); System.out.println(ss); pw.println(ss); }
while (iter.hasNext()) { JIRAFeature jirafeaturetemp = iter.next(); ArrayList<SprintUserStory> undoneUserStoriesList = SprintUtil.getUndoneUserStoriesList(jirafeaturetemp.getID(),jirafeaturetemp.getPkey()); if(undoneUserStoriesList.size() >0){ willdonefeautre--; }