Java Collection Join join(Collection collection, String joinString)

Here you can find the source of join(Collection collection, String joinString)

Description

join

License

Apache License

Declaration

public static String join(Collection<? extends Object> collection,
            String joinString) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Collection;
import java.util.Iterator;

public class Main {
    public static String join(Collection<? extends Object> collection,
            String joinString) {/*from  w  ww  .  j a v  a 2s .  co  m*/
        StringBuilder sb = new StringBuilder();
        Iterator<? extends Object> iter = collection.iterator();
        while (iter.hasNext()) {
            sb.append(iter.next());
            if (iter.hasNext()) {
                sb.append(joinString);
            }
        }
        return sb.toString();
    }
}

Related

  1. join(Collection strings, String sep)
  2. join(Collection strings, String separator)
  3. join(Collection tokens, String separator)
  4. join(Collection var0, Object var1)
  5. join(Collection c, String joinWith)
  6. join(Collection collection, String separator)
  7. join(Collection elements, String separator)
  8. join(Collection list, String separator)
  9. join(Collection objects, String delim)