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

Stringjoin(Object[] array, String glue)
join
return join(Arrays.asList(array), glue);
Stringjoin(Object[] array, String linker)
join
StringBuilder stringBuilder = new StringBuilder();
if (null == array || 0 == array.length) {
    return stringBuilder.toString();
stringBuilder.append(array[0]);
for (int i = 1; i < array.length; i++) {
    stringBuilder.append(linker).append(array[i]);
return stringBuilder.toString();
Stringjoin(Object[] array, String sep)
Perform reverse of split on a list.
if (array.length == 0) {
    return "";
StringBuilder result = new StringBuilder();
boolean afterFirst = false;
for (Object o : array) {
    if (afterFirst) {
        result.append(sep);
...
Stringjoin(Object[] array, String separator)
join
if (array == null) {
    return null;
return join(array, separator, 0, array.length);
Stringjoin(Object[] array, String separator)

Joins the elements of the provided array into a single String containing the provided list of elements.

No delimiter is added before or after the list.

if (array == null) {
    return null;
StringBuilder builder = new StringBuilder();
for (int i = 0; i < array.length; i++) {
    Object o = array[i];
    if (i > 0) {
        builder.append(separator);
...
Stringjoin(Object[] array, String separator)
join array of strings by separator
StringBuilder ret = new StringBuilder();
for (int i = 0; i < array.length; i++) {
    if (i != 0) {
        if (separator != null) {
            ret.append(separator);
    ret.append(array[i]);
...
Stringjoin(Object[] array, String separator)

Joins the elements of the provided array into a single String containing the provided list of elements.

No delimiter is added before or after the list.

if (array == null) {
    return null;
return join(array, separator, 0, array.length);
Stringjoin(Object[] array, String separator)
Joins the elements of the given array to a string, separated by the given separator string.
return array != null ? join(Arrays.asList(array), separator) : null;
Stringjoin(Object[] array, String separator)
Join the objects in array with the given separator Useful for making a comma separated list, or URL query string
int num = array.length;
if (num == 0)
    return "";
String out = array[0].toString();
for (int ii = 1; ii < num; ii++) {
    out += (separator + array[ii].toString());
return out;
...
Stringjoin(Object[] array, String separator)
Joins the elements of the given array to a string, separated by the given separator string.
return array != null ? join(Arrays.asList(array), separator) : null;