Understanding concurrentModificationException and implementation of ArrayList
<p>I tried to reproduce ConcurrentModificationException myself by writing the following code:</p>

<pre><code>List&lt;String&gt; last = new ArrayList&lt;&gt;();
last.add("a");
last.add("b");
for(String i : last){
    System.out.println(i);
    last.remove(i);
}
System.out.println(last);
</code></pre>

<p><a href="http://ideone.com/rIO27k" rel="nofollow">DEMO</a></p>

<p>Since, the <a href="https://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html" rel="nofollow">documentation of <code>ArrayList</code> mentioned</a></p>

<blockquote>
  <p>Note that the fail-fast behavior of an iterator cannot be guaranteed
  as it is, generally speaking, impossible to make any hard guarantees
  in the presence of unsynchronized concurrent modification.</p>
</blockquote>

<p>I expected that in single-threaded programs such detection is straghtforward. But the program printed</p>

<pre><code>a
[b]
</code></pre>

<p>instead. Why?</p>