Android String Array Join implode(String[] strings, String glue)

Here you can find the source of implode(String[] strings, String glue)

Description

implode

License

Open Source License

Declaration

static public String implode(String[] strings, String glue) 

Method Source Code

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

import java.util.List;

public class Main {
    static public String implode(String[] strings, String glue) {
        StringBuilder stringBuilder = new StringBuilder();
        if (strings == null)
            return "";
        for (int i = 0; i < strings.length; i++) {
            stringBuilder.append(strings[i]);
            if (i != strings.length - 1) {
                stringBuilder.append(glue);
            }/*  w w w.j a va 2  s .c o  m*/
        }
        return stringBuilder.toString();
    }

    static public String implode(List<String> strings, String glue) {
        StringBuilder stringBuilder = new StringBuilder();
        if (strings == null)
            return "";
        for (int i = 0; i < strings.size(); i++) {
            stringBuilder.append(strings.get(i));
            if (i != strings.size() - 1) {
                stringBuilder.append(glue);
            }
        }
        return stringBuilder.toString();
    }
}

Related

  1. concatenate(String[] elements, String delimiter)
  2. makeDivideString(String[] arr_str, String divide_str)
  3. join(String spliter, Object[] arr)
  4. joinStrings(String joiner, Iterable parts)