Java List Join join(final List strings, final String separator)

Here you can find the source of join(final List strings, final String separator)

Description

join

License

Open Source License

Declaration

public static String join(final List<String> strings, final String separator) 

Method Source Code

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

import java.util.List;

public class Main {
    public static String join(final List<String> strings, final String separator) {
        if (strings == null) {
            return "";
        }/*from  ww  w . j  a  v  a 2  s.  c o m*/
        return join(strings.toArray(new String[strings.size()]), separator);
    }

    public static String join(final String[] strings, final String separator) {
        return join(strings, 0, strings.length, separator);
    }

    public static String join(final String[] strings, int startIndex, int endIndex, final String separator) {
        final StringBuilder result = new StringBuilder();
        for (int i = startIndex; i < endIndex; i++) {
            if (i > startIndex)
                result.append(separator);
            result.append(strings[i]);
        }
        return result.toString();
    }
}

Related

  1. join(final List data, String separator)
  2. join(final List list)
  3. join(final List list, final String sepa)
  4. join(final List path, final char delimiter)
  5. join(final List strings, final String delimiter)
  6. join(final List substrings, final String join)
  7. join(final String delimiter, List values)
  8. join(final String separator, final List list)
  9. join(final String with, final List array)