Java ArrayList Implode implode(ArrayList elements, String connector)

Here you can find the source of implode(ArrayList elements, String connector)

Description

implode

License

Open Source License

Declaration

public static String implode(ArrayList elements, String connector) 

Method Source Code

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

import java.util.ArrayList;

public class Main {
    public static String implode(ArrayList elements, String connector) {
        String retValue = null;/*from w ww .  ja va2  s.  c  o  m*/
        // clauseElements is a ArrayList with Strings in it; connector is to conncet the elements
        if (elements.size() > 0) {
            retValue = "";
            int size = elements.size();
            for (int i = 0; i < size; i++) {
                if (i > 0) {
                    retValue += connector;
                }
                retValue += elements.get(i).toString();
            }
        }
        return retValue;
    }
}

Related

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