title: ConcurrentModificationException and HashSet.iterator()
body: <p>I have a for loop like</p>
  
  <pre><code>      for (int neighbour : neighbours) {
  </code></pre>
  
  <p>Where I may modify <code>neighbours</code> within the loop. Found that thats the cause of <code>ConcurrentModificationException</code>. And read from <a href="https://stackoverflow.com/a/8189527/292291">https://stackoverflow.com/a/8189527/292291</a></p>
  
  <blockquote>
    <p>Hence if you want to modify the list (or any collection in general),
    <strong>use iterator</strong>, because then it is aware of the modifications and hence
    those will be handled properly.</p>
  </blockquote>
  
  <p>So I tried: </p>
  
  <pre><code>neighboursItr = neighbours.iterator();
  while (neighboursItr.hasNext()) {
    // try disconnecting vertices
    neighbour = neighboursItr.next();
  </code></pre>
  
  <p>But that doesnt fix the problem. Why?</p>