Java Collection Element Get getFlatString(Collection elements)

Here you can find the source of getFlatString(Collection elements)

Description

get Flat String

License

LGPL

Declaration

public static String getFlatString(Collection<? extends Object> elements) 

Method Source Code

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

import java.util.Collection;

public class Main {
    public static String getFlatString(Collection<? extends Object> elements) {
        return getFlatString(",", false, elements.toArray());
    }//from  w  ww  . j  a  v a2s. c  o m

    public static String getFlatString(String seperator, boolean skipNulls, Object... elements) {
        StringBuilder builder = new StringBuilder();
        boolean firstWritten = false;
        for (int index = 0; index < elements.length; index++) {
            if (!skipNulls || elements[index] != null) {
                if (firstWritten) {
                    builder.append(seperator);
                } else {
                    firstWritten = true;
                }
                builder.append(elements[index]);
            }
        }
        return builder.toString();
    }
}

Related

  1. getElement(final int index, final Collection coll)
  2. getElementClass(Collection collection)
  3. getElementFromSize1(Collection collection)
  4. getEntropy(Collection values)
  5. getEnumNames( Collection values)
  6. getGivenClassObject(Collection coll, Class clazz)
  7. getHighest(final Collection elements, final Comparator c)
  8. getImplement(Class aClass, Collection> classCollection)
  9. getIndex(Object collectionOrArray, int index)