Java ArrayList Implode implode(String glue, ArrayList strings)

Here you can find the source of implode(String glue, ArrayList strings)

Description

implode

License

Open Source License

Declaration

public static String implode(String glue, ArrayList<String> strings) 

Method Source Code

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

import java.util.ArrayList;

public class Main {
    public static String implode(String glue, ArrayList<String> strings) {
        if (strings.isEmpty()) {
            return "";
        }//w  ww . j a va  2 s  . com

        StringBuilder builder = new StringBuilder();
        builder.append(strings.remove(0));

        for (String str : strings) {
            builder.append(glue);
            builder.append(str);
        }

        return builder.toString();
    }
}

Related

  1. implode(ArrayList elements, String connector)
  2. implode(String glue, ArrayList array)
  3. implode(String glue, ArrayList list)