Here you can find the source of toString(List
static String toString(List<String> strings)
//package com.java2s; /******************************************************************************* * Copyright (c) 2008, 2010 VMware Inc.//from w w w. jav a 2 s. c o m * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * VMware Inc. - initial contribution *******************************************************************************/ import java.util.Iterator; import java.util.List; public class Main { static String toString(List<String> strings) { if (strings.isEmpty()) { return null; } StringBuilder builder = new StringBuilder(); Iterator<String> iterator = strings.iterator(); while (iterator.hasNext()) { builder.append(iterator.next()); if (iterator.hasNext()) { builder.append(","); } } return builder.toString(); } }