title: Java - HashMap Iteration - Exception
body: <p>I want to iterate a HashMap like:</p>
  
  <pre><code>        for (Map.Entry&lt;Integer, Integer&gt; entry : map.entrySet()) {
              map.replace(entry.getKey(), entry.getValue()-1);
              if (entry.getValue() == 0) {
                  map.remove(entry.getKey(), 0);
              }
          }
  </code></pre>
  
  <p>This ends in an Exception: java.util.ConcurrentModificationException</p>
  
  <p>Any solutions?</p>
  
  <p>Kind regards</p>