Java Utililty Methods List to Primitive Array

List of utility methods to do List to Primitive Array

Description

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

Method

double[]toPrimitiveArray(List array)
to Primitive Array
double[] primitiveArray = new double[array.size()];
for (int i = 0; i < array.size(); ++i) {
    primitiveArray[i] = array.get(i).doubleValue();
return primitiveArray;
double[]toPrimitiveArray(List input)
toPrimitiveArray
double[] output = new double[input.size()];
for (int i = 0; i < input.size(); i++) {
    output[i] = input.get(i);
return output;
double[]toPrimitiveArray(List list)
to Primitive Array
double[] arr = new double[list.size()];
for (int i = 0; i < list.size(); i++)
    arr[i] = list.get(i);
return arr;
int[]toPrimitiveArray(List target_)
to Primitive Array
if (target_ == null)
    return null;
int[] array = new int[target_.size()];
for (int i = 0; i < array.length; i++)
    array[i] = target_.get(i).intValue();
return array;
long[]toPrimitivebyList(List list)
to Primitiveby List
int nullcounter = 0;
for (Long l : list) {
    if (l == null) {
        nullcounter++;
long[] result = new long[list.size() - nullcounter];
nullcounter = 0;
...
double[]toPrimitiveDouble(List values)
to Primitive Double
double[] result = new double[values.size()];
Iterator<Double> iterator = values.iterator();
for (int i = 0; i < result.length; i++) {
    result[i] = iterator.next().doubleValue();
return result;
int[]toPrimitiveIntArray(List temp)
to Primitive Int Array
int nItems = temp.size();
if (nItems < 1) {
    return null;
Integer[] boxInts = new Integer[nItems];
temp.toArray(boxInts);
int[] result = new int[nItems];
for (int i = 0; i < result.length; i++) {
...
ObjecttoPrimitiveIntArray(List values)
to Primitive Int Array
int[] array = new int[values.size()];
int cursor = 0;
for (Object o : values) {
    array[cursor] = (Integer) o;
    cursor++;
return array;
int[]toPrimitiveIntegerArray(List listOfInt)
to Primitive Integer Array
int[] result = new int[listOfInt.size()];
int i = 0;
for (Integer n : listOfInt) {
    result[i++] = n;
return result;
long[]toPrimitiveLongArray(List items)
Convert a Long list to a long array
final long[] res = new long[items.size()];
for (int i = 0; i < res.length; i++)
    res[i] = items.get(i);
return res;