title: Getting ConcurrentModifcationException even while iterating using iterator
body: <p>I have the following method:</p>
  
  <pre><code>//Cleans any stop words at the beginning of the sentence, returns the remaining
  //sentence.
  public static String cleanBeginning(String sentence, boolean skipEmpty)
  {
      List&lt;String&gt; words = Common.getWords(sentence, skipEmpty);
      int i = 0;
      Iterator&lt;String&gt; iterator = words.iterator();
      while (iterator.hasNext() )
      {
          String word = iterator.next();
          if ( stopWords.contains( word.toLowerCase() ) )
          {
              words.remove(i);
              continue;
          }
          break;
      }
  
      StringBuilder sb = new StringBuilder();
      for (String cleanedWord : words)
      {
          sb.append(cleanedWord ).append(" ");
      }
  
      return sb.toString().trim();
  }
  </code></pre>
  
  <p>On the line:
  <code>String word = iterator.next();</code></p>
  
  <p>I get a <code>java.util.ConcurrentModificationException</code>. Why is that? I thought <code>iterator.next()</code> was supposed to be a safe way to loop over an arraylist? Am i doing anything wrong?</p>