Java Collection to Array toStringArray(final Collection collection)

Here you can find the source of toStringArray(final Collection collection)

Description

to String Array

License

Apache License

Declaration

public static String[] toStringArray(final Collection<?> collection) 

Method Source Code

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

import java.util.Collection;

public class Main {
    public static String[] toStringArray(final Collection<?> collection) {
        if (collection == null) {
            return null;
        }/*from   w  w w.j  a va  2 s .  c  o  m*/
        final String[] retval = new String[collection.size()];
        int i = 0;
        for (final Object o : collection) {
            retval[i] = String.valueOf(o);
            i = i + 1;
        }
        return retval;
    }
}

Related

  1. toStringArray(Collection collection)
  2. toStringArray(Collection items)
  3. toStringArray(Collection list)
  4. toStringArray(Collection strings)
  5. toStringArray(final Collection fields)
  6. toStringArray(final Collection c)