package com.novoda.notils.string;

import java.util.Collection;
import java.util.Iterator;

public abstract class StringUtils {

    public static String join(Collection<?> s, String delimiter) {
        StringBuilder builder = new StringBuilder();
        Iterator<?> iter = s.iterator();
        while (iter.hasNext()) {
            builder.append(iter.next());
            if (!iter.hasNext()) {
                break;
            }
            builder.append(delimiter);
        }
        return builder.toString();
    }
}

@@ -264,18 +264,16 @@
 or%3C?%3E it
-er
  = s.ite
@@ -277,24 +277,56 @@
 iterator();%0A
+        String separator = %22%22;%0A%0A
         whil
@@ -330,18 +330,16 @@
 hile (it
-er
 .hasNext
@@ -371,20 +371,36 @@
 .append(
+separator).append(
 it
-er
 .next())
@@ -417,106 +417,67 @@
     
-if (!iter.hasNext()) %7B%0A                break;%0A            %7D%0A            builder.append(delimiter);
+separator = delimiter; //use delimiter from the 2nd time on
 %0A   

Optimize loop