Android String Array to String Convert implode(String[] array, String glue)

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

Description

implode

Declaration

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

Method Source Code

//package com.java2s;

import java.util.Iterator;
import java.util.List;

public class Main {
    public static String implode(String[] array, String glue) {
        String str = "";
        for (int i = 0; i < array.length; i++) {
            if (i < array.length - 1) {
                str += array[i] + glue;//from   ww  w  . ja v a 2  s  .c  om
            } else {
                str += array[i];
            }
        }
        return str;

    }

    public static String implode(List list, String glue) {
        String str = "";
        int i = 0;
        for (Iterator it = list.iterator(); it.hasNext();) {
            Object object = (Object) it.next();
            if (i < list.size() - 1) {
                str += object.toString() + glue;
            } else {
                str += object.toString();
            }
            i++;
        }
        return str;

    }
}

Related

  1. StringArrayToString(List array)
  2. StringArrayToString(String[] array)
  3. getConcatenatedString(String... args)
  4. arrayToString(String[] array)