Java Array Join join(Object[] array, String linker)

Here you can find the source of join(Object[] array, String linker)

Description

join

License

Apache License

Declaration

public static String join(Object[] array, String linker) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {
    public static String join(Object[] array, String linker) {
        StringBuilder stringBuilder = new StringBuilder();
        if (null == array || 0 == array.length) {
            return stringBuilder.toString();
        }/*from   w  w w.  j a v  a2s.  c  o  m*/
        stringBuilder.append(array[0]);
        for (int i = 1; i < array.length; i++) {
            stringBuilder.append(linker).append(array[i]);
        }
        return stringBuilder.toString();
    }

    @SuppressWarnings("rawtypes")
    public static String join(List list, String linker) {
        return join(list.toArray(), linker);
    }
}

Related

  1. join(Object[] array, char separator, int startIndex, int endIndex)
  2. join(Object[] array, String delim)
  3. join(Object[] array, String delimiter)
  4. join(Object[] array, String delimiter)
  5. join(Object[] array, String glue)
  6. join(Object[] array, String sep)
  7. join(Object[] array, String separator)
  8. join(Object[] array, String separator)
  9. join(Object[] array, String separator)