Here you can find the source of prettyPrintArrayList(ArrayList
Parameter | Description |
---|---|
input | A List of Strings, e.G. List(1,2,3) |
public static String prettyPrintArrayList(ArrayList<String> input)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Iterator; public class Main { /**/*from www . j av a 2s . c o m*/ * Makes an ArrayList of Strings pretty again! * * @param input * A List of Strings, e.G. List(1,2,3) * @return A pretty pretty String, e.G. 1,2,3 */ public static String prettyPrintArrayList(ArrayList<String> input) { StringBuilder sb = new StringBuilder(); Iterator<String> i = input.iterator(); while (i.hasNext()) { String next = i.next(); sb.append(next); if (i.hasNext()) sb.append(", "); } return sb.toString(); } }