Java List to String listToString(List list)

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

Description

list To String

License

Apache License

Declaration

public static final String listToString(List<? extends Object> list) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {
    public static final String listToString(List<? extends Object> list) {
        if (null == list)
            return "";

        if (list.isEmpty())
            return "[]";
        StringBuilder sb = new StringBuilder("[");
        for (int i = 0; i < list.size(); i++) {
            sb.append(list.get(i));/*from w  w  w. jav a  2  s  .c om*/
            if (i != (list.size() - 1)) {
                sb.append(',');
            }
        }
        sb.append(']');

        return sb.toString();
    }
}

Related

  1. listToString(List list, char sep)
  2. listToString(List list, String delim)
  3. listToString(List list, String glue)
  4. listToString(List list, String prefix, String suffix, String separator)
  5. listToString(List list)
  6. listToString(List list, String delim)
  7. listToString(List list, String header, String separator, String footer)
  8. ListToString(List lista)
  9. listToString(List collection)