Last iteration of for loop in java
<p>Is there a way to determine if the loop is iterating for the last time. My code looks something like this:</p>

<pre><code>int[] array = {1, 2, 3...};
StringBuilder builder = new StringBuilder();

for(int i : array)
{
    builder.append("" + i);
    if(!lastiteration)
        builder.append(",");
}
</code></pre>

<p>Now the thing is I don't want to append the comma in the last iteration. Now is there a way to determine if it is the last iteration or am I stuck with the for loop or using an external counter to keep track.</p>
