Java does not permit altering a map while iterating over it to avoid non-deterministic behavior later on. The following code sample, for example, throws a java. Util. ConcurrentModificationException occurred because the Map interface's delete() function was used during iteration.