I have a program that loops through a HashMap using an Iterator, and inside the loop, I'm adding to the HashMap - which is causing a ConcurrentModificationException. I've seen that ListIterator has an add() function that handles this, but Iterator does not.
The HashMap is set up like this -
HashMap<Pair<Integer, Integer>, Object>
And the iterator like this -
Iterator<Entry<Pair<Integer, Integer>, Object>> iter;
With Object (not the real name) being a class from my program. Does anybody know how I can go about adding to the iterator while I'm looping or any other options?