I have written this code to join ArrayList elements: Can it be optimized more? Or is there a better different way doing this?
public static String join(ArrayList list, char delim) {
StringBuffer buf = new StringBuffer();
for (int i = 0; i < list.size(); i++) {
if (i != 0)
buf.append(delim);
buf.append((String) list.get(i));
}
return buf.toString();
}
See Question&Answers more detail:os