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

int[]asArray(Collection list)
as Array
final int[] result = new int[list.size()];
int index = 0;
for (Integer integer : list) {
    result[index++] = integer;
return result;
double[]asArray(List values)
as Array
double[] array = new double[values.size()];
for (int i = 0; i < values.size(); i++) {
    array[i] = values.get(i);
return array;
int[]asArray(List indices)
as Array
int[] _indices = new int[indices.size()];
for (int i = 0; i < indices.size(); i++)
    _indices[i] = indices.get(i);
return _indices;
String[]asArray(List list)
as Array
if (null == list) {
    return null;
String[] res = new String[list.size()];
list.toArray(res);
return res;
T[]asArray(List list)
Converts a list to an array of the same type.
return (T[]) list.toArray();
ArrayListasArrayList(E first, E... other)
as Array List
if (other == null) {
    throw new NullPointerException("other");
ArrayList<E> list = new ArrayList<>(1 + other.length);
list.add(first);
list.addAll(Arrays.asList(other));
return list;
ArrayListasArrayList(T... a)
as Array List
return new ArrayList<T>(Arrays.asList(a));
boolean[]asBooleanArray(List list)
as Boolean Array
int n = list.size();
boolean[] array = new boolean[n];
for (int i = 0; i < n; i++) {
    array[i] = list.get(i);
return array;
byte[]asByteArray(final List l)
Return list of boxed bytes as a primitive array.
final byte[] a = new byte[l.size()];
for (int i = 0; i < a.length; i++) {
    a[i] = l.get(i);
return a;
Class[]asClassArray(List> list)
as Class Array
Class<?>[] asArray = new Class[list.size()];
int i = 0;
for (Class<?> t : list) {
    asArray[i++] = t;
return asArray;