title: Detecting the first iteration through a for-each loop in Java
body: <p>I'm working on a server that returns character separated lists to its client.
  In order to build these lists I have to detect the first iteration through a for-each loop:</p>
  
  <pre><code>    StringBuilder builder = new StringBuilder() ;
      boolean firstIterationFlag = true ;
  
      for ( String s : list ){
          if ( firstIterationFlag) {
              firstIterationFlag = false ;
          } else {
              builder.append(separator);
          }
          builder.append(s) ;         
     }
     return builder.toString() ;
  </code></pre>
  
  <p>Is there a way of doing this without the flag?</p>