You need to sign in to do that
Don't have an account?
Remove duplicates from list
Hi,
I'm trying to remove duplicate eleements from a list using iterator and it's not allowing me to do so, saying that you can't modify the list while iterating the same.
Iterator<InvoiceLineItem__c> itr = invoiceLineItems.iterator();
while(itr.hasNext()){
for (integer i = 0; i < invoiceLineItems.size(); i++){
if (itr.next() == invoiceLineItems.get(i)){
invoiceLineItems.remove(i);
}
}
}
If you guys knowing any of it's solutions than plz let me know. thanks in advance ................ :)
Hi ....
try below code ....
You are trying to remove element from the same list that is being iterated. Try iterating with a cloned list.
@DeepaAnika.Ankali
hi,
Thanks for the consideration but it's still same. So tell me if you have any other solution.
thanks but it's all the same....... do you have any other idea.....
@ask001
Once u get the iterator() u can't modify the List...
Thanks,
Cool Sfdc