title: Cannot cast iterator
body: <p>Hello I am having the same problems taking data from a collection with an iterator:</p>
  
  <p>I have a class called DatabaseTableFieldUIData which has a method getFieldName.</p>
  
  <p>In another class I have a collection of DatabaseTableFieldUIDatas like this:</p>
  
  <p>Collection columnData</p>
  
  <p>Now I want to go through that collection with an iterator to get all the field names with getFieldName method. So I tried something like this:</p>
  
  <pre><code>Iterator&lt;DatabaseTableFieldUIData&gt; it = columnData.iterator();
  for (int i = 0; i &lt; columnData.size(); i++)
          String fieldName = it.getFieldName();
  </code></pre>
  
  <p>but it doesn't allow me to call getFieldName method from the iterator, so I tried casting the iterator to DatabaseTableFieldUIData:</p>
  
  <pre><code>Iterator&lt;DatabaseTableFieldUIData&gt; it = columnData.iterator();
      DatabaseTableFieldUIData aux;
      for (int i = 0; i &lt; columnData.size(); i++)
          aux = (DatabaseTableFieldUIData) it;
  </code></pre>
  
  <p>And I get the error "Cannot cast from Iterator to DatabaseTableFieldUIData", don't know what to do right now :(</p>
  
  <p>Thanks for the help.</p>