Here you can find the source of join(List
public static <T> String join(List<T> values, String separator)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { public static <T> String join(List<T> values, String separator) { StringBuilder result = new StringBuilder(); for (Object value : values) { String v = value.toString().trim(); if (hasLength(v)) { if (result.length() > 0) { result.append(separator); }//from ww w .ja v a2 s . c om result.append(v); } } return result.toString(); } public static boolean hasLength(String str) { return str != null && str.length() > 0; } }