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

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

Description

Concats the String[] array data to a single String, using the specified delimiter as the glue.

License

Open Source License

Parameter

Parameter Description
data the strings that should be concatinated
delimiter the delimiter

Return

the concatinated string

Declaration

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

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//  w ww  . java2  s  .  c o m
     * Concats the String[] array data to a single String, using the specified delimiter as the
     * glue. <code>implode({"A", "B", "C"}, ";")</code> would result in A;B;C
     * 
     * @param data the strings that should be concatinated
     * @param delimiter the delimiter
     * @return the concatinated string
     */
    public static String implode(String[] data, String delimiter) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < data.length; i++) {
            if (i != 0) {
                sb.append(delimiter);
            }

            sb.append(data[i]);
        }

        return sb.toString();
    }
}

Related

  1. implode(String[] arr_str, String pemisah)
  2. implode(String[] array, char delimiter)
  3. implode(String[] array, String glue)
  4. implode(String[] array, String separator)
  5. implode(String[] array, String separator)
  6. implode(String[] input)
  7. implode(String[] segments, String delimiter)
  8. implode(String[] strings, String delimiter)
  9. implode(String[] stringsArr, String glue)