I'm having problem with my delete command of my array list while I'm iterating it. How can I resolve the ConcurrentModificationException
?
protected void deleteModeOfPayment(List<List<String>> AllModeOfPayment) {
int ctr=0;
List<String> thePayments =new ArrayList<String>();
Iterator<List<String>> ia=allModeOfPayment.iterator();
while(ia.hasNext()){
thePayments=ia.next();
String refOne= thePayments.get(1).toString().trim();
if(refOne.equals(referenceIdentity)){
log.d("ALVIN","ITEM TO BE DELETE FOUND");
allModeOfPayment.remove(ctr);
}
else{
ctr++;
log.d("ALVIN","ITEM TO BE DELETE NOT FOUND");}
}
}
}