Here you can find the source of join(List extends Object> valueList, String separator)
public static String join(List<? extends Object> valueList, String separator)
//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(); } }