I'm trying to add an item to the ArrayList in a certain order
Iterator<Rating> it = arr.iterator();
while(it.hasNext()){
Rating o = it.next();
int index = arr.indexOf(o);
if(o.getRating() < this.getRating()) {
arr.add(index, this);
}
}
I get a ConcurrentModificationException when trying to do it. Is there some simple solution to solve this problem?