Possible Duplicate:
Concurrent Modification Exception : adding to an ArrayList
I'm attempting to remove duplicate values from an arraylist with this method:
public void hasDuplicates(List<Artifact> p_cars) {
final List<String> usedNames = new ArrayList<String>();
for (Artifact car : p_cars) {
final String name = car.getObjectId();
if (usedNames.contains(name)) {
p_cars.remove(car);
}
usedNames.add(name);
}
}
How can I remove these duplicate values without concurrent modifying the arraylist?
I'm doing this on an arraylist that populates a listview if that helps with the context.
Thanks!