Java Collection Join join(final Collection coll, final String glue)

Here you can find the source of join(final Collection coll, final String glue)

Description

join

License

Open Source License

Declaration

public static String join(final Collection<?> coll, final String glue) 

Method Source Code


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

import java.util.Collection;

public class Main {
    public static String join(final Collection<?> coll, final String glue) {
        return join(coll.toArray(new Object[coll.size()]), glue);
    }/*from w ww. j a  va 2  s. c om*/

    public static String join(final Object[] list, final String glue) {
        StringBuilder ret = new StringBuilder(100);
        for (int i = 0; i < list.length; i++) {
            if (i != 0) {
                ret.append(glue);
            }
            ret.append(list[i]);
        }
        return ret.toString();
    }
}

Related

  1. join(final char _separator, final boolean _quotes, final Collection _list, final String _emptyString)
  2. join(final Collection collection, String delimiter)
  3. join(final Collection e, final String s)
  4. join(final Collection items, final String glue)
  5. join(final Collection coll, final String delimiter)
  6. join(final Collection items, final String inBetween)
  7. join(final Collection list, final String inbetween)
  8. join(final Collection strings, String delimeter)
  9. join(final Collection values, final String separator)

    HOME | Copyright © www.java2s.com 2016