Using the iterator over the same set more than once in java
<p>Say I'm iterating over a set in java, e.g.</p>

<pre><code>Iterator&lt;_someObject_&gt; it = _someObject_.iterator();
</code></pre>

<p>well, first I want to go through every object in the set and make a change to each object I visit. So I use:</p>

<pre><code>while(it.hasNext()) {
        _someObject_ = it.next();
        _someObject_.add3();       //made up method
    }
</code></pre>

<p>Now that I've done this, I decide I want to iterate through the entire set from start to finish once more to carry out another method on them, given that I've just made changes to each element through my first iteration.</p>

<p>Can I just use </p>

<pre><code>while(it.hasNext())
</code></pre>

<p>again?</p>

<p>I thought maybe the iterator has a pointer so once it's reached the last element on the first run through, if I call <code>while(it.hasNext())</code> again, the pointer would still be at the end of the set, meaning my second while loop would be pointless.</p>
