Java Utililty Methods Collection to Array

List of utility methods to do Collection to Array

Description

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

Method

String[]toStringArray(Collection collection)
Returns an array containing string representations of the elements in the collection.
String[] result = new String[collection.size()];
int index = 0;
for (Object entry : collection) {
    result[index] = String.valueOf(entry);
    index += 1;
return result;
String[]toStringArray(Collection collection)
to String Array
if (collection == null)
    throw new RuntimeException("Can't do toStringArray. Collection is Null");
return collection.toArray(new String[collection.size()]);
String[]toStringArray(Collection collection)
to String Array
if (collection == null) {
    return null;
return collection.toArray(new String[collection.size()]);
String[]toStringArray(Collection collection)
to String Array
return collection != null ? collection.toArray(new String[collection.size()]) : null;
String[]toStringArray(Collection collection)
to String Array
return collection == null || collection.isEmpty() ? EMPTY_STRING_ARRAY
        : toArray(collection, new String[collection.size()]);
String[]toStringArray(Collection items)
Convert a collection of strings into a string array.
String[] result = new String[items.size()];
int i = 0;
for (String s : items) {
    result[i++] = s;
return result;
String[]toStringArray(Collection list)
Converts a collection of String s to a String array.
return list.toArray(new String[list.size()]);
String[]toStringArray(Collection strings)
INTERNAL: Utility method that converts a collection of strings to an array of strings.
String[] _strings = new String[strings.size()];
strings.toArray(_strings);
return _strings;
String[]toStringArray(final Collection fields)
Converts a Collection to an array of Strings.
final String[] defaultFields = new String[fields.size()];
int i = 0;
for (final Object f : fields) {
    defaultFields[i++] = f.toString();
return defaultFields;
String[]toStringArray(final Collection collection)
to String Array
if (collection == null) {
    return null;
final String[] retval = new String[collection.size()];
int i = 0;
for (final Object o : collection) {
    retval[i] = String.valueOf(o);
    i = i + 1;
...