Here you can find the source of listToString(List list, String glue)
public static String listToString(List list, String glue)
//package com.java2s; /******************************************************************************* * Copyright (c) 2014 Gabriel Skantze./* w ww .j a v a 2s . c om*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html * * Contributors: * Gabriel Skantze - initial API and implementation ******************************************************************************/ import java.util.List; public class Main { public static String listToString(List list, String glue) { String result = ""; boolean first = true; for (Object item : list) { if (!first) result += glue; result += item.toString(); first = false; } return result; } public static String listToString(List list) { return listToString(list, " "); } }