title: Why am I not getting a java.util.ConcurrentModificationException in this example?
body: <p>Note: I am aware of the <code>Iterator#remove()</code> method.</p>
  
  <p>In the following code sample, I don't understand why the <code>List.remove</code> in <code>main</code> method throws <code>ConcurrentModificationException</code>, but <strong>not</strong> in the <code>remove</code> method.</p>
  
  <pre><code>public class RemoveListElementDemo {    
      private static final List&lt;Integer&gt; integerList;
  
      static {
          integerList = new ArrayList&lt;Integer&gt;();
          integerList.add(1);
          integerList.add(2);
          integerList.add(3);
      }
  
      public static void remove(Integer toRemove) {
          for(Integer integer : integerList) {
              if(integer.equals(toRemove)) {                
                  integerList.remove(integer);
              }
          }
      }
  
      public static void main(String... args) {                
          remove(Integer.valueOf(2));
  
          Integer toRemove = Integer.valueOf(3);
          for(Integer integer : integerList) {
              if(integer.equals(toRemove)) {                
                  integerList.remove(integer);
              }
          }
      }
  }
  </code></pre>