Java List Join join(List list, String delimiter)

Here you can find the source of join(List list, String delimiter)

Description

Joins elements in List with a delimiter String

License

Open Source License

Parameter

Parameter Description
list a parameter
delimiter a parameter

Declaration

public static String join(List list, String delimiter) 

Method Source Code


//package com.java2s;

import java.util.List;

public class Main {
    /**/*  www  .java  2 s.c  om*/
     * Joins elements in {@link List} with a delimiter {@link String}
     * 
     * @param list
     * @param delimiter
     * @return
     */
    public static String join(List list, String delimiter) {
        String out = "";
        for (int i = 0; i < list.size(); i++) {
            out += list.get(i);
            if (i < list.size() - 1) {
                out += delimiter;
            }
        }
        return out;
    }
}

Related

  1. join(List elements, String sep)
  2. join(List items, String separator)
  3. join(List l, String sep)
  4. join(List list, char separator)
  5. join(List list, String delim)
  6. join(List list, String flag)
  7. join(List list, String separator)
  8. join(List list, String separator)
  9. join(List objects)