Java List Print printListWithDelimiter(Collection list, String delimiter)

Here you can find the source of printListWithDelimiter(Collection list, String delimiter)

Description

print List With Delimiter

License

LGPL

Declaration

public static <T> String printListWithDelimiter(Collection<T> list, String delimiter) 

Method Source Code

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

import java.util.*;

public class Main {
    public static <T> String printListWithDelimiter(Collection<T> list, String delimiter) {
        boolean first = true;
        StringBuilder sb = new StringBuilder();
        for (T el : list) {
            if (first) {
                first = false;//from w  w w . j av  a  2s.  com
            } else {
                sb.append(delimiter);
            }
            sb.append(el);
        }
        return sb.toString();
    }
}

Related

  1. printList(List list)
  2. printList(List list)
  3. printListPair(List list)
  4. printListStrings(List list, String listDescription)
  5. printListV(List l)
  6. println(List text)
  7. printlnList(List list)
  8. printMap(HashMap> listHashMap)
  9. printNonEmptyList(List list)