Java ArrayList Implode implode(String glue, ArrayList array)

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

Description

implode

License

Open Source License

Declaration

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

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> array) {
        return implode(glue, array.stream().toArray(String[]::new));
    }//from   w ww  . j  a va 2s . c  om

    public static String implode(String glue, String[] array) {
        StringBuilder sb = new StringBuilder();
        boolean f = true;
        for (String a : array) {
            if (f) {
                f = false;
            } else {
                sb.append(glue);
            }
            sb.append(a);
        }
        return sb.toString();
    }
}

Related

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