Java String Join join(String glue, Iterable items)

Here you can find the source of join(String glue, Iterable items)

Description

join

License

Open Source License

Declaration

public static String join(String glue, Iterable<String> items) 

Method Source Code

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

import java.util.Arrays;

public class Main {
    public static String join(String glue, String[] items) {
        return join(glue, Arrays.asList(items));
    }/*  w  ww.jav  a  2  s  . co  m*/

    public static String join(String glue, Iterable<String> items) {
        StringBuilder ret = new StringBuilder();

        boolean first = true;
        for (String item : items) {
            if (first) {
                first = false;
            } else {
                ret.append(glue);
            }

            ret.append(item);
        }

        return ret.toString();
    }
}

Related

  1. join(String delimiter, Object... parts)
  2. join(String delimiter, String... items)
  3. join(String delimiter, String... params)
  4. join(String delimiter, String... strings)
  5. join(String delimiter, T... array)
  6. join(String glue, String... str)
  7. join(String joiner, String... toJoin)
  8. join(String s, Object... objects)
  9. join(String sep, Object... pieces)