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 String listToString(List<String> list) 

Method Source Code

//package com.java2s;
/*//w  w w  . j  ava  2 s  . c o m
 * codjo.net
 *
 * Common Apache License 2.0
 */

import java.util.List;

public class Main {
    public static String listToString(List<String> list) {
        StringBuilder result = new StringBuilder();

        if (list == null) {
            return "";
        }
        for (String aList : list) {
            result.append(aList).append(", ");
        }
        if (!list.isEmpty()) {
            return result.substring(0, result.length() - 2);
        } else {
            return result.toString();
        }
    }
}

Related

  1. listToString(List value)
  2. listToString(List args)
  3. listToString(List l, String sep)
  4. ListToString(List list)
  5. listToString(List list)
  6. listToString(List list)
  7. listToString(List list)
  8. listToString(List list)
  9. listToString(List list)

  10. HOME | Copyright © www.java2s.com 2016