Here you can find the source of toString(List extends Object> list)
Parameter | Description |
---|---|
list | The list containing the elements. |
public static String toString(List<? extends Object> list)
//package com.java2s; //License from project: Open Source License import java.util.Iterator; import java.util.List; public class Main { /**/*w ww.j a v a 2 s .c o m*/ * Builds a string containing the names of each list element separated * by comma. * * @param list The list containing the elements. * * @return The string containing the names of each list element separated * by comma. */ public static String toString(List<? extends Object> list) { String result = ""; for (Iterator<? extends Object> it = list.iterator(); it.hasNext();) { Object obj = it.next(); if (it.hasNext()) { result += obj.toString() + ", "; } else { result += obj.toString(); } } return result; } }