Java List to String listToString(List list, String prefix, String delimiter, String suffix)

Here you can find the source of listToString(List list, String prefix, String delimiter, String suffix)

Description

list To String

License

BSD License

Declaration

public static <T> String listToString(List<T> list, String prefix, String delimiter, String suffix) 

Method Source Code


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

import java.util.List;

public class Main {
    public static <T> String listToString(List<T> list, String prefix, String delimiter, String suffix) {
        String listStr = prefix;/*  ww  w . ja v a 2  s . c  o  m*/
        boolean isFirst = true;
        for (T element : list) {
            listStr += (isFirst ? "" : delimiter) + element.toString();
            isFirst = false;
        }
        listStr += suffix;

        return listStr;
    }
}

Related

  1. listToString(List elements)
  2. listToString(List lines)
  3. listToString(List list)
  4. listToString(List list)
  5. listToString(List list)
  6. listToString(List list, String sep)
  7. listToString(String itemName, List list)
  8. toString(final List list)
  9. toString(final List list, final String separtor)