Java Collection Join join(Collection strs, String sep)

Here you can find the source of join(Collection strs, String sep)

Description

join

License

Apache License

Declaration

public static String join(Collection<String> strs, String sep) 

Method Source Code


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

import java.util.Collection;

public class Main {
    public static String join(String[] strs, String sep) {
        StringBuilder bud = new StringBuilder();
        for (String s : strs) {
            if (bud.length() > 0)
                bud.append(sep);/*from   ww  w. ja v a  2s.c o m*/
            bud.append(s);
        }
        return bud.toString();
    }

    public static String join(Collection<String> strs, String sep) {
        StringBuilder bud = new StringBuilder();
        for (String s : strs) {
            if (bud.length() > 0)
                bud.append(sep);
            bud.append(s);
        }
        return bud.toString();
    }
}

Related

  1. join(Collection strings, String sep)
  2. join(Collection strings, String sep)
  3. join(Collection strings, String separator)
  4. join(Collection strings, String separator)
  5. join(Collection strings, String token)
  6. join(Collection thisPath, String _delim)
  7. join(Collection values)
  8. join(Collection words, String character)
  9. join(Collection c, String concatinator)