Java Collection Join join(String glue, Collection strings)

Here you can find the source of join(String glue, Collection strings)

Description

join

License

Open Source License

Declaration

public static String join(String glue, Collection<String> strings) 

Method Source Code

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

import java.util.*;

public class Main {
    public static String join(String glue, Collection<String> strings) {
        StringBuilder b = new StringBuilder();
        boolean first = true;
        for (String s : strings) {
            if (!first) {
                b.append(glue);/*from  ww w.  j a v  a 2s .co  m*/
            }
            first = false;
            b.append(s);
        }
        return b.toString();
    }

    public static String join(String glue, String[] strings) {
        StringBuilder b = new StringBuilder();
        boolean first = true;
        for (String s : strings) {
            if (!first) {
                b.append(glue);
            }
            first = false;
            b.append(s);
        }
        return b.toString();
    }
}

Related

  1. join(String delimiter, Collection strings)
  2. join(String delimiter, Collection values)
  3. join(String glue, Collection c)
  4. join(String glue, Collection pieces)
  5. join(String glue, Collection c)
  6. join(String glue, Collection items)
  7. join(String join_string, Collection c)
  8. join(String joiner, Collection strings)
  9. join(String sep, Collection objects)