Here you can find the source of join(List
public static String join(List<String> values)
//package com.java2s; /*/*from w w w. java2 s .com*/ * Copyright (c) 2011 - 2012. Elega9t Ltd. All rights reserved. * ELEGA9T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.Copyright (c) 2011 - 2012. Elega9t Ltd. All rights reserved. */ import java.util.List; public class Main { public static String join(List<String> values) { return join(values, ", "); } public static String join(List<String> values, String separator) { StringBuilder joined = new StringBuilder(); for (int i = 0, valuesSize = values.size(); i < valuesSize; i++) { String value = values.get(i); joined.append(value); if (i < values.size() - 1) { joined.append(separator); } } return joined.toString(); } }