Java List Implode implode(List list, String delimiter)

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

Description

implode

License

Open Source License

Declaration

public static String implode(List<String> list, String delimiter) 

Method Source Code


//package com.java2s;
/*/* w ww . j a  v  a 2 s  .co m*/
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

import java.util.List;

public class Main {
    public static String implode(List<String> list, String delimiter) {
        String implodedString = "";
        if (list != null) {
            for (String element : list) {
                if (implodedString.length() > 0) {
                    implodedString += delimiter;
                }
                implodedString += element;
            }
        }
        return implodedString;
    }
}

Related

  1. implode(Collection list, String separator)
  2. implode(final List pieces, final String glue)
  3. implode(List list, String deliminator)
  4. implode(List objs, String delim)
  5. implode(List elements, String separator)
  6. implode(List list, String glue)
  7. implode(List list, String glue)
  8. implode(List strings, String separator)
  9. implode(List tokens, char separator, char escapeCharacter)