Here you can find the source of join(List extends Object> list)
public static String join(List<? extends Object> list)
//package com.java2s; /**/*from w w w . j a v a 2 s .c o m*/ * Copyright (c) 2012 Baozun All Rights Reserved. * * This software is the confidential and proprietary information of Baozun. * You shall not disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Baozun. * * BAOZUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE, OR NON-INFRINGEMENT. BAOZUN SHALL NOT BE LIABLE FOR ANY DAMAGES * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING * THIS SOFTWARE OR ITS DERIVATIVES. * */ import java.util.List; public class Main { public static final String DELIM = ","; public static String join(List<? extends Object> list) { return join(list, DELIM); } public static String join(Object[] arr) { return join(arr, DELIM); } public static String join(List<? extends Object> list, String seperator) { if (list == null || list.size() == 0) return ""; Object[] t = new Object[0]; return join(list.toArray(t), seperator); } public static String join(Object[] arr, String seperator) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < arr.length; i++) { sb.append(seperator + arr[i]); } if (sb.length() > 0) sb.deleteCharAt(0); return sb.toString(); } }