Java Utililty Methods Array Join

List of utility methods to do Array Join

Description

The list of methods to do Array Join are organized into topic(s).

Method

StringjoinString(String[] str, String delimiter)
Join an array of strings into a string.
return joinString(str, delimiter, 0);
String[]joinStringArray(String[] array1, String[] array2)
Join 2 String array into one
List<String> l = new ArrayList<String>();
for (String string : array1)
    l.add(string);
for (String string : array2)
    l.add(string);
return l.toArray(new String[l.size()]);
StringjoinStrings(String[] strings, String separator)
Join an array of strings into a single string using a separator
if (strings == null) {
    return null;
String res = "";
for (int i = 0; i < strings.length; i++) {
    res += (i > 0) ? separator : "";
    res += strings[i];
return res;
StringjoinTokens(String tokens[], String pad)
Join the words in the array into a String.
StringBuffer sb = new StringBuffer();
int n = tokens.length;
for (int i = 0; i < n - 1; i++) {
    sb.append(tokens[i]);
    sb.append(pad);
sb.append(tokens[n - 1]);
String s = new String(sb);
...
StringjoinWithPrefixes(String[] prefixes, String name, String sep)
Returns the name, joined to prefixes, if any, using the default #PACKAGE_SEP if none supplied.
if (isVarArgsEmpty(prefixes)) {
    return name;
} else { 
    if (sep == null) {
        sep = PACKAGE_SEP;
    return join(prefixes, sep) + sep + name;
StringjoinWithSpaces(final String[] cmds)
join With Spaces
return join(" ", cmds);
StringstringJoin(Object[] array, String separator)
string Join
if (array == null)
    return null;
return stringJoin(Arrays.asList(array).iterator(), separator);