Android List Join implode(List list, String glue)

Here you can find the source of implode(List list, String glue)

Description

implode

Declaration

public static String implode(List list, 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;/*  w ww.  j  av  a2  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. implode(List strings, String glue)
  2. join(List texts, String separator)
  3. join(String separator, List data)
  4. concatenate(List elements, String delimiter)
  5. toCommaSeperatedList(List values)
  6. joinList(String seperator, List list)
  7. joinList(String seperator, List list, String def)