title: How to remove and add elements to TreeMap while iterating?
body: <p>I want to write code like this -</p>
  
  <pre><code>for (Map.Entry&lt;Long, Integer&gt; e : map.entrySet()){
      map.remove(k);
      map.put(x, value);
  }
  </code></pre>
  
  <p>but I got <code>java.util.ConcurrentModificationException</code>
  I tried to use <code>Iterator</code> also but I got the same <code>Exception</code></p>