Java Array Join join(String[] strings, char delimiter)

Here you can find the source of join(String[] strings, char delimiter)

Description

join

License

Open Source License

Declaration

public static String join(String[] strings, char delimiter) 

Method Source Code

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

import java.util.Arrays;
import java.util.List;

public class Main {
    public static String join(String[] strings, char delimiter) {

        if (strings == null) {
            return null;
        }/*  w  w  w.j av a  2  s .  c  om*/

        List<String> stringsAsList = Arrays.asList(strings);
        return join(stringsAsList, delimiter);
    }

    public static String join(List<String> strings, char delimiter) {

        if (strings == null) {
            return null;
        }

        StringBuilder retString = new StringBuilder();

        if (!strings.isEmpty()) {
            for (int i = 0; i < strings.size() - 1; i++) {
                retString.append(strings.get(i));
                retString.append(delimiter);
            }
            retString.append(strings.get(strings.size() - 1));
        }

        return retString.toString();
    }
}

Related

  1. join(String[] stringArray, boolean quote, String glue)
  2. join(String[] stringArray, String delimiter)
  3. join(String[] stringArray, String delimiterString, boolean joinNullValues)
  4. join(String[] stringArray, String separator)
  5. join(String[] strings)
  6. join(String[] strings, char delimiter)
  7. join(String[] strings, String glue)
  8. join(String[] strings, String glue)
  9. join(String[] strings, String separator)