Java List to String toString(List list)

Here you can find the source of toString(List list)

Description

to String

License

Open Source License

Declaration

private static <T> String toString(List<T> list) 

Method Source Code

//package com.java2s;
/*//  ww  w  . j  av  a 2 s  .  c  o  m
 // This software is subject to the terms of the Eclipse Public License v1.0
 // Agreement, available at the following URL:
 // http://www.eclipse.org/legal/epl-v10.html.
 // You must accept the terms of that agreement to use this software.
 //
 // Copyright (C) 2003-2005 Julian Hyde
 // Copyright (C) 2005-2011 Pentaho
 // All Rights Reserved.
 */

import java.util.*;

public class Main {
    private static <T> String toString(List<T> list) {
        StringBuilder buf = new StringBuilder();
        int k = -1;
        for (T t : list) {
            if (++k > 0) {
                buf.append(", ");
            }
            buf.append(t);
        }
        return buf.toString();
    }
}

Related

  1. toString(List list, String split)
  2. toString(List strings)
  3. toString(List strings)
  4. toString(List list)
  5. toString(List list)
  6. toStringClassList(List list)
  7. toStringDelimited(final Iterable list, final String delimiter)
  8. toStringItem(List> itemMapList, String subjectName)
  9. toStringList(Collection strings, String separator)