Here you can find the source of listToString(List extends Object> list, String header, String separator, String footer)
Parameter | Description |
---|---|
list | The List to be represented as a String |
header | The String prepended to the String representation |
separator | The String separating each List element |
footer | The String appended to the String representation |
public static String listToString(List<? extends Object> list, String header, String separator, String footer)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { /**// w ww. jav a2 s. c o m * * @param list The List to be represented as a String * @param header The String prepended to the String representation * @param separator The String separating each List element * @param footer The String appended to the String representation * * @return The String representation of the List */ public static String listToString(List<? extends Object> list, String header, String separator, String footer) { String delim = ""; StringBuilder sb = new StringBuilder(header); for (int i = 0; i < list.size(); i++) { sb.append(delim).append("" + list.get(i)); delim = separator; } return sb.append(footer).toString(); } }