title: How can I fix Exception in thread "main" java.util.ConcurrentModificationException
body: <p>I have 2 <code>HashMap&lt;Integer,Point3D&gt;</code> objects names are <code>positiveCoOrdinate and negativeCoOrdinates</code>.</p>
  
  <p>I am checking <code>PositiveCoOrdinates</code> with following condition.if it satisfies that corresponding point adding into <code>negativeCoOrdinates</code> and deleting from <code>positiveCoOrdinates</code>.</p>
  
  <pre><code>  HashMap&lt;Integer, Point3d&gt; positiveCoOrdinates=duelList.get(1);
    HashMap&lt;Integer, Point3d&gt; negativecoOrdinates=duelList.get(2);
    //condition
    Set&lt;Integer&gt; set=positiveCoOrdinates.keySet();
      for (Integer pointIndex : set) {
          Point3d coOrdinate=positiveCoOrdinates.get(pointIndex);
          if (coOrdinate.x&gt;xMaxValue || coOrdinate.y&gt;yMaxValue || coOrdinate.z&gt;zMaxValue) {
              negativecoOrdinates.put(pointIndex, coOrdinate);
              positiveCoOrdinates.remove(pointIndex);
          }
      }
  </code></pre>
  
  <p>While adding,deleting time I am getting the following error.</p>
  
  <pre><code> Exception in thread "main" java.util.ConcurrentModificationException
  at java.util.HashMap$HashIterator.nextEntry(Unknown Source)
  at java.util.HashMap$KeyIterator.next(Unknown Source)
  at PlaneCoOrdinates.CoordinatesFiltering.Integration(CoordinatesFiltering.java:167)
  at PlaneCoOrdinates.CoordinatesFiltering.main(CoordinatesFiltering.java:179)
  </code></pre>
  
  <p>For my testing,I mention <code>System.out.println(coOrdinate.x);</code> statement inside <code>If</code> condition.it's working fine.</p>
  
  <p>If I add 2 lines(What I mention above) inside <code>If</code> condition,it throwing error.</p>
  
  <p>How can I fix this.</p>
  
  <p>Thanks.</p>