public static String join(final CharSequence separator, final Iterable<?> objectsToJoin) {
        if (objectsToJoin == null) {
            return EMPTY_STRING;
        }
        final StringBuilder stringBuilder = new StringBuilder();
        if (isEmpty(separator)) {
            // No separator - merging strings.
            for (final Object element : objectsToJoin) {
                stringBuilder.append(element);
            }
            return stringBuilder.toString();
        }
        // A separator is selected - joining strings with selected separator.
        int index = 0;
        for (final Object object : objectsToJoin) {
            if (index++ > 0) {
                stringBuilder.append(separator);
            }
            stringBuilder.append(object);
        }
        return stringBuilder.toString();
    }
public static String join ( final CharSequence separator , final Iterable < ? > objectsToJoin ) { if ( objectsToJoin == null ) { return EMPTY_STRING ; } final StringBuilder stringBuilder = new StringBuilder ( ) ; if ( isEmpty ( separator ) ) { for ( final Object element : objectsToJoin ) { stringBuilder . append ( element ) ; } return stringBuilder . toString ( ) ; } int index = 0 ; for ( final Object object : objectsToJoin ) { if ( index ++ > 0 ) { stringBuilder . append ( separator ) ; } stringBuilder . append ( object ) ; } return stringBuilder . toString ( ) ; }
@param separator will be used to separate joined strings from each other. Passing null or empty string will
result in merging strings without any separation.
@param objectsToJoin will be converted to strings and joined using the selected separator. Nulls are converted
into "null" strings.
@return passed objects as strings joined into one object. Note that this string will never be null - if
objectsToJoin are empty, an empty string is returned.