無法弄清楚爲什麼這是循環無限。Java迭代器無限循環
public void DLCCheck(IconSet iconSet) {
Log.d(TAG, "Got dlc check. Looking to see if we need to remove any notes from the current list.");
int foundCount = 0;
for(Iterator<Item> i = mItemList.iterator(); i.hasNext();) {
if(i instanceof NoteItem && ((NoteItem) i).getIconSet() == iconSet) {
i.remove();
foundCount++;
}
}
Log.d(TAG, "Finished searching. Found " + foundCount + "notes in the current list to delete.");
//notifyDataSetChanged();
//EventBus.getDefault().post(new MoveNoteListOut());
}
當hasNext返回false時,不應該停止迭代嗎?這個列表中只有6個項目,但它永遠循環。
這實際上是有幫助的。爲什麼這個題外話? – dan