Java Collection Join join(String sep, Collection strings)

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

Description

join

License

Apache License

Declaration

static String join(String sep, Collection<String> strings) 

Method Source Code


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

import java.util.Collection;

public class Main {
    static String join(String sep, Collection<String> strings) {
        StringBuilder sb = new StringBuilder();
        boolean first = true;
        for (String s : strings) {
            if (!first) {
                sb.append(sep);//from   w ww.  j  a va2  s . c o m
            } else {
                first = false;
            }
            sb.append(s);
        }
        return sb.toString();
    }

    static String join(char c, Collection<String> strings) {
        return join(String.valueOf(c), strings);
    }
}

Related

  1. join(String sep, Collection col)
  2. join(String sep, Collection col)
  3. join(String sep, Collection parts)
  4. join(String sep, Collection values)
  5. join(String sep, Collection values)
  6. join(String sep, Collection strs)
  7. join(String separator, Collection c)
  8. join(String separator, Collection c)
  9. join(String separator, Collection items)