I have a system that involves loading 'PlayerValue' Objects. The objects are formatted as such: [Header] value. I have these saved in a text file and whenever I save or read from the file, I want to remove duplicate headers. So I did this:
first, I load all of the PlayerValues from the file into an ArrayList called 'array', then:
for (PlayerValue v : array) {
for (PlayerValue v1 : array) {
if (v1.header.equals(v.header)) {
array.remove(v1);
}
}
}
Here you can see, it goes through each item of the array, then for each item, it searches the array again for the same header.
This would effectively remove duplicate headers, except for the fact that it throws a ConcurrentModificationException.
Any help for a work around?