No, not in the current Java library.
In JDK7 you should be able to write String.join("", strings)
. It was found that "85%" of the uses for wanting an index in the posh for loop was to do a string join (which you can do without anyway).
I guess if you want to be uber efficient, you could write it as something like:
public static String concat(String... strs) {
int size = 0;
for (String str : strs) {
size += str.length;
}
final char[] cs = new char[size];
int off = 0;
try {
for (String str : strs) {
int len = str.length();
str.getChars(0, len, cs, off);
off += len;
}
} catch (ArrayIndexOutOfBoundsException exc) {
throw new ConcurrentModificationException(exc);
}
if (off != cs.length) {
throw new ConcurrentModificationException();
}
return new String(cs);
}
(Not compiled or tested, of course.)