Java Iterable Join join(Iterable strings, String separator)

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

Description

join

License

Open Source License

Declaration

public static String join(Iterable<String> strings, String separator) 

Method Source Code


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

import java.util.Iterator;

public class Main {
    public static String join(Iterable<String> strings, String separator) {
        StringBuilder builder = new StringBuilder();
        if (strings != null) {
            Iterator<String> iter = strings.iterator();
            while (iter.hasNext()) {
                String part = iter.next();
                builder.append(part);/*  w  w w . ja v a2s . c  o m*/
                if (iter.hasNext()) {
                    builder.append(separator);
                }
            }
        }
        return builder.toString();
    }
}

Related

  1. join(Iterable s, String delimiter)
  2. join(Iterable source, char delimiter)
  3. join(Iterable source, String separator)
  4. join(Iterable strings)
  5. join(Iterable strings, String delimiter)
  6. join(Iterable array, String joiner)
  7. join(Iterable coll, String sep)
  8. join(Iterable coll, String sep)
  9. join(Iterable coll, String sep)