title: ConcurrentModificationException - checkForComodification(ArrayList.java)
body: <p>For the Below java program with Hash Map, ConcurrentModification Exception thrown, i had marked the lines where the Exception is thrown in the Program.</p>
  
  <p>I had skipped the login of Insertion of Data into the HashMap for now</p>
  
  <pre><code>import java.util.ArrayList;
   import java.util.HashMap;
  
   public class MainClass {
  
       public static void main(String[] args) {
  
           ArrayList&lt;HashMap&lt;String, ArrayList&lt;String&gt;&gt;&gt; arrMain = new ArrayList&lt;HashMap&lt;String, ArrayList&lt;String&gt;&gt;&gt;();
  
           HashMap&lt;String, ArrayList&lt;String&gt;&gt; hm = new HashMap&lt;String, ArrayList&lt;String&gt;&gt;();
  
           ArrayList&lt;String&gt; strings = new ArrayList&lt;String&gt;();
  
           // Code to build the above Maps with all required Data, Skipped for Now
  
           //******************Scenario 1****************
           for (HashMap&lt;String, ArrayList&lt;String&gt;&gt; dataMap : arrMain) { //ConcurrentModification Exception
               for (String s : dataMap.get("Key")) {
                   ArrayList&lt;String&gt; newStrings = new ArrayList&lt;String&gt;();
                   newStrings.addAll(dataMap.get("Key")); 
                   newStrings.add("New String");
                   dataMap.put("Key", newStrings);
               }
  
           }
  
           //******************Scenario 2****************
           for (HashMap&lt;String, ArrayList&lt;String&gt;&gt; dataMap : arrMain) {//ConcurrentModification Exception
               for (String s : dataMap.get("Key")) {
                   dataMap.get("Key").add("New String"); 
               }
  
           }
  
       }
  
   }
  </code></pre>
  
  <p>Error :</p>
  
  <pre><code>java.util.ConcurrentModificationException
      at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:819)
      at java.util.ArrayList$Itr.next(ArrayList.java:791)
  </code></pre>