Here you can find the source of join(List array, String separator)
@SuppressWarnings("unchecked") public static String join(List array, String separator)
//package com.java2s; /**/*from ww w . ja v a2 s. c o m*/ * Project: SmartCNP * * File Created at 2012-8-30 * $Id$ * * Copyright 2010 dianping.com. * All rights reserved. * * This software is the confidential and proprietary information of * Dianping Company. ("Confidential Information"). 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 dianping.com. */ import java.util.List; public class Main { public static final String EMPTY = ""; @SuppressWarnings("unchecked") public static String join(List array, String separator) { if (array == null) { return null; } if (separator == null) { separator = EMPTY; } StringBuffer buf = new StringBuffer(); for (int i = 0; i < array.size(); i++) { if (i > 0) { buf.append(separator); } if (array.get(i) != null) { buf.append(array.get(i)); } } return buf.toString(); } }