Java Utililty Methods List to Array

List of utility methods to do List to Array

Description

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

Method

String[]listToArray(List list)
list To Array
final int size = list.size();
String[] str = (String[]) list.toArray(new String[size]);
return str;
Object[]listToArray(List list)
list To Array
if (list == null) {
    return new Object[] {};
Object[] arr = new Object[list.size()];
return list.toArray(arr);
Object[]listToArray(List list)
Convert List to Array[]
if (list == null) {
    return null;
} else {
    Object valueArr[] = new Object[list.size()];
    list.toArray(valueArr);
    return valueArr;
byte[]listToArray(List bytes)
list To Array
byte[] buffer;
buffer = new byte[bytes.size()];
int i = 0;
for (Byte b : bytes) {
    buffer[i++] = b;
return buffer;
Comparable[]listToArray(List list)
list To Array
Comparable[] array = new Comparable[list.size()];
int i = 0;
for (Comparable c : list) {
    array[i] = c;
    i++;
return array;
double[]listToArray(List doubles)
Convert a list of Doubles to an array of primitive double types.
double[] array = new double[doubles.size()];
for (int i = 0; i < doubles.size(); i++) {
    array[i] = doubles.get(i);
return array;
double[]listToArray(List list)
list To Array
double[] arr = new double[list.size()];
for (int i = 0; i < list.size(); ++i)
    arr[i] = list.get(i);
return arr;
float[]listToArray(List list)
list To Array
int size = list != null ? list.size() : 0;
float[] floatArr = new float[size];
for (int i = 0; i < size; i++) {
    floatArr[i] = list.get(i);
return floatArr;
int[]ListToArray(List list)
Convert a List of Integer s to an array of ints.
if (list == null) {
    return null;
int count = list.size();
int[] result = new int[count];
for (int i = 0; i < count; ++i) {
    result[i] = list.get(i);
return result;
int[]listToArray(List list)
list To Array
if (isEmpty(list)) {
    return null;
int[] result = new int[list.size()];
for (int i = 0; i < result.length; i++) {
    result[i] = list.get(i);
return result;
...