0
for(PatientProcedures s: PatientProceduresList)
{
if(Num == s.getAccountNumber())
{
PatientProceduresList.remove(s);
break;
//without break it stops cause of loop
}
}
反正有這個嗎?它適用於中斷,但我需要繼續並繼續對陣列列表的其他部分做同樣的事情。ArrayList爲循環刪除多於1個?
如果刪除'break;',它將刪除任何與Num匹配的s值。 – christopher 2013-03-03 19:54:54
如果他刪除了中斷,那麼它將拋出一個'ConcurrentModificationException'。 – pickypg 2013-03-03 19:55:16
除非使用迭代器,否則在遍歷數組時不能從數組列表中刪除。查看javadoc以獲取更多信息。 – 2013-03-03 19:55:16