Android List Join joinList(String seperator, List list, String def)

Here you can find the source of joinList(String seperator, List list, String def)

Description

join List

Declaration

public static String joinList(String seperator,
            List<? extends Object> list, String def) 

Method Source Code

//package com.java2s;

import java.util.List;

public class Main {
    public static String joinList(String seperator,
            List<? extends Object> list) {
        return joinList(seperator, list, "");
    }//  ww  w.j  a v  a 2 s  .c  o m

    public static String joinList(String seperator,
            List<? extends Object> list, String def) {
        if (list.isEmpty())
            return def;
        StringBuilder b = new StringBuilder();
        boolean first = true;
        for (Object s : list) {
            if (!first)
                b.append(seperator);
            b.append(s.toString());
            first = false;
        }
        return b.toString();
    }
}

Related

  1. join(String separator, List data)
  2. concatenate(List elements, String delimiter)
  3. toCommaSeperatedList(List values)
  4. implode(List list, String glue)
  5. joinList(String seperator, List list)