Here you can find the source of listToString(List list)
Parameter | Description |
---|---|
list | list to convert |
public static String listToString(List list)
//package com.java2s; /******************************************************************************* * Copyright (c) 2008 Mountainminds GmbH & Co. KG * This software is provided under the terms of the Eclipse Public License v1.0 * See http://www.eclipse.org/legal/epl-v10.html. * * $Id: $//from w ww . ja va 2s . c om ******************************************************************************/ import java.util.List; public class Main { /** * converts a list to a string taking every element and separating them with * a , comma. * * @param list * list to convert * @return string with all elements separated with , comma */ public static String listToString(List list) { StringBuffer result = new StringBuffer(); for (int i = 0; i < list.size(); i++) { result.append(", " + list.get(i)); } return result.substring(2); } }