Java String Implode implode(Object[] data, String delimiter)

Here you can find the source of implode(Object[] data, String delimiter)

Description

implode

License

Open Source License

Declaration

public static String implode(Object[] data, String delimiter) 

Method Source Code

//package com.java2s;

public class Main {
    /**//w w w  . j a va2s .com
     * Empty String.
     */
    public final static String EMPTY = "";

    public static String implode(Object[] data) {
        return implode(data, ", ");
    }

    public static String implode(Object[] data, String delimiter) {
        String implodedString;
        if (data.length == 0) {
            implodedString = EMPTY;
        } else {
            StringBuffer sb = new StringBuffer();
            sb.append(data[0]);
            for (int i = 1; i < data.length; i++) {
                sb.append(delimiter);
                sb.append(data[i]);
            }
            implodedString = sb.toString();
        }
        return implodedString;
    }
}

Related

  1. implode(char delimiter, char escape, String... input)
  2. implode(final char separator, final Object... array)
  3. implode(final String separator, final Iterable data)
  4. implode(Object strarr[], String delim)
  5. implode(Object[] elements, String delimiter)
  6. implode(Object[] source, String delimiter)
  7. implode(String delim, Object[] array)
  8. implode(String delimiter, String[] strings)