Java Utililty Methods Collection Convert

List of utility methods to do Collection Convert

Description

The list of methods to do Collection Convert are organized into topic(s).

Method

StringtoLimitLengthString(final Collection coll, final int limit)
Creates a string representation according to the java.util.AbstractCollection#toString() method, but with a limited length param.
if (fallBackToStandardImplementation(coll, limit)) {
    return coll.toString();
final Iterator<E> iter = coll.iterator();
final StringBuilder sb = new StringBuilder();
sb.append('[');
final int min = Math.min(coll.size(), limit);
for (int i = 0; i < min; i++) {
...
ListtoLowerCase(Collection values)
to Lower Case
List<String> result = new ArrayList<String>();
for (String value : values)
    result.add(value.toLowerCase());
return result;
MaptoMap(Collection names, Object[] parameters)
to Map
return toMap(names.toArray(new String[0]), parameters);
int[][]toMatrix(Collection collection)
to Matrix
int[][] result = new int[collection.size()][];
int index = 0;
for (int[] array : collection) {
    result[index++] = array;
return result;
Object[]toObjectArray(Collection list)
to Object Array
Object[] array = new Object[list.size()];
int i = 0;
for (Object value : list)
    array[i++] = value;
return array;
CollectiontoObjectCollection(Object v)
to Object Collection
return (Collection<Object>) v;
StringtooDelimitedString(final Collection coll, final String delim, final String prefix, final String suffix)
Convenience method to return a Collection as a delimited (e.g.
if (coll == null) {
    return "";
final StringBuilder sb = new StringBuilder();
Iterator it = coll.iterator();
int i = 0;
while (it.hasNext()) {
    if (i > 0) {
...
double[]toPrimitiveArray(final Collection values)
Returns a primative array of the passed Collection .
double[] results = new double[values.size()];
int index = 0;
Iterator<Double> iter = values.iterator();
while (iter.hasNext()) {
    Double value = iter.next();
    if (value != null) {
        results[index] = value;
        index++;
...
int[]toPrimitiveIntegerArray(Collection collection)
to Primitive Integer Array
int[] result = new int[collection.size()];
int i = 0;
for (Integer n : collection) {
    result[i++] = n;
return result;
StringtoReadableString(Collection collection)
to Readable String
Iterator it = collection.iterator();
StringBuilder strb = new StringBuilder();
while (it.hasNext()) {
    Object next = it.next();
    strb.append(next.toString() + ", ");
if (strb.length() > 2) {
    strb.delete(strb.length() - 2, strb.length());
...