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

static String toString(List<?> list) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.List;

public class Main {
    static String toString(List<?> list) {
        if (list == null)
            return "null";

        StringBuilder sb = new StringBuilder();

        sb.append('[');
        for (Object element : list) {
            sb.append(element);// w  w  w . j av  a 2 s  .co  m
            sb.append(',');
        }
        sb.setLength(sb.length() - 1);
        sb.append(']');

        return sb.toString();
    }
}

Related

  1. toString(List col)
  2. toString(List coll, char delimiter)
  3. toString(List list)
  4. toString(List list)
  5. toString(List list)
  6. toString(List list, char sep)
  7. toString(List list, String separator)
  8. toString(List objects)
  9. toString(List c)