title: List throws ConcurrentModificationException but set does not throws ConcurrentModificationException?
body: <p>I have below two java class</p>
  
  <pre><code>import java.util.*;
  
  public class ArrayListTest032 {
      public static void main(String[] ar) {
          List&lt;String&gt; list = new ArrayList&lt;String&gt;();
          list.add("core java");
          list.add("php");
          list.add("j2ee");
          list.add("struts");
          list.add("hibernate");
  
          Iterator&lt;String&gt; itr = list.iterator();
  
          while (itr.hasNext()) {
              System.out.println(itr.next());
          }
          list.remove("php");
  
          while (itr.hasNext()) {
              System.out.println(itr.next());
          }
  
      }
  }
  </code></pre>
  
  <p>When I run above code I get below output.</p>
  
  <pre><code>core java
  php
  j2ee
  struts
  hibernate
  
  Exception in thread "main" java.util.ConcurrentModificationException
      at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
      at java.util.AbstractList$Itr.next(AbstractList.java:343)
      at ArrayListTest032.main(ArrayListTest032.java:20)
  </code></pre>
  
  <p>Which is expected as I am modifying the list while iterating. But in below java class same logic is executed by set family.</p>
  
  <pre><code>import java.util.*;
  
  public class HashSetTest021 {
      public static void main(String[] ar) {
          Set&lt;String&gt; set = new HashSet&lt;String&gt;();
          set.add("core java");
          set.add("php");
          set.add("j2ee");
          set.add("struts");
          set.add("hibernate");
  
          Iterator&lt;String&gt; itr = set.iterator();
  
          while (itr.hasNext()) {
              System.out.println(itr.next());
          }
          set.remove("php");
  
          while (itr.hasNext()) {
              System.out.println(itr.next());
          }
  
      }
  }
  </code></pre>
  
  <p>And out put is.</p>
  
  <pre><code>hibernate
  core java
  j2ee
  php
  struts
  </code></pre>
  
  <p>There is no any <strong>ConcurrentModificationException</strong>.</p>
  
  <p>I just want to know why same piece of code throws  <strong>ConcurrentModificationException</strong> in case of <code>list</code> family, but there is no any <strong>ConcurrentModificationException</strong> in case of <code>set</code> family</p>