Java List Join join(List valueList, String separator)

Here you can find the source of join(List valueList, String separator)

Description

join

License

Open Source License

Declaration

public static String join(List<? extends Object> valueList, String separator) 

Method Source Code

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

import java.util.List;

public class Main {
    public static String join(List<? extends Object> valueList, String separator) {
        if (valueList == null || valueList.size() == 0) {
            throw new IllegalArgumentException("valueList might not be null or empty!");
        }//from  w  w w . ja v  a 2 s.  com
        if (separator == null) {
            throw new IllegalArgumentException("separator might not be null!");
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < valueList.size(); i++) {
            sb.append(valueList.get(i).toString());
            if (i + 1 < valueList.size()) {
                sb.append(separator);
            }
        }
        return sb.toString();
    }
}

Related

  1. join(List s, String delimiter)
  2. join(List items, String conjunction)
  3. join(List items, String separator)
  4. join(List list)
  5. join(List olist, String glue)
  6. join(List words, String iDelimiter)
  7. join(List list, T element)
  8. join(List _items, String _delim)
  9. join(List arr, String seperator)