Java ArrayList Join Join(ArrayList coll, String delimiter)

Here you can find the source of Join(ArrayList coll, String delimiter)

Description

Join

License

Open Source License

Declaration

public static String Join(ArrayList<String> coll, String delimiter) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

public class Main {
    public static String Join(ArrayList<String> coll, String delimiter) {
        if (coll.isEmpty())
            return "";

        StringBuilder sb = new StringBuilder();

        for (String x : coll)
            sb.append(x + delimiter);//from w w w  .j  a va 2 s .c  o m

        sb.delete(sb.length() - delimiter.length(), sb.length());

        return sb.toString();
    }
}

Related

  1. join(ArrayList list, String delimeter)
  2. join(ArrayList arr, String separator)
  3. join(ArrayList list)
  4. join(ArrayList list, String delimiter)
  5. Join(ArrayList list, String delimiter)
  6. join(ArrayList list, String joinChar)