Best practice: treating first element different than the others while looping over a collection
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/10502503/detecting-the-first-iteration-through-a-for-each-loop-in-java">Detecting the first iteration through a for-each loop in Java</a>  </p>
</blockquote>



<p>Hi while looping over a collection i want to find the smartest way to generate different behavior on only the first element in the collection. I'm faced with this problem very often and feel like my solution is not the best:</p>

<pre><code>boolean first = true;
for(String foo: foos) {
   if(first) {
     // do first behavior
     first = false;
     continue;
   }
   // do normal behaviour
}
</code></pre>

<p>i'm wondering are there any other smarter approaches than this?</p>
