Java Collection Join join(Collection list, String conjunction)

Here you can find the source of join(Collection list, String conjunction)

Description

join

License

Open Source License

Declaration

public static String join(Collection<String> list, String conjunction) 

Method Source Code


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

import java.util.Collection;

public class Main {
    public static String join(Collection<String> list, String conjunction) {
        StringBuilder sb = new StringBuilder();
        if (conjunction == null) {
            conjunction = ", ";
        }/*from  w  w w.  ja  v  a 2  s  . c o m*/

        if (list != null && !list.isEmpty()) {
            for (String string : list) {
                sb.append(string).append(conjunction);
            }

            sb.setLength(sb.length() - conjunction.length());
        }

        return sb.toString();
    }
}

Related

  1. join(Collection in, String joinS)
  2. join(Collection items)
  3. join(Collection items, String join)
  4. join(Collection items, String prefix, String suffix, String itemPrefix, String itemSuffix)
  5. join(Collection list)
  6. join(Collection packs)
  7. join(Collection s, String delimiter)
  8. join(Collection s, String delimiter)
  9. join(Collection src, String delim)