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[]convertStringListToArray(List list)
Konwertuje liste typu String do tablicy.
String[] result = new String[list.size()];
list.toArray(result);
return result;
String[]convertStringListToArray(List list)
convert String List To Array
if (list == null) {
    return new String[0];
String array[] = new String[list.size()];
for (int i = 0; i < list.size(); i++) {
    array[i] = list.get(i);
return array;
...
Object[][]convertToArray(final List> list)
convert To Array
final Object[][] array = new Object[list.size()][];
int i = 0;
for (List<Object> nestedList : list) {
    array[i++] = nestedList.toArray(new Object[nestedList.size()]);
return array;
int[]convertToArray(List list)
convert To Array
int[] array = new int[list.size()];
Iterator<Integer> iterator = list.iterator();
for (int i = 0; i < array.length; i++)
    array[i] = iterator.next().intValue();
return array;
ObjectconvertToArray(List args)
convert To Array
String[] array = new String[args.size()];
args.toArray(array);
return array;
double[]listToArray(final List list)
List to array.
double[] array = new double[list.size()];
for (int i = 0; i < array.length; i++) {
    array[i] = list.get(i).doubleValue();
return array;
double[]listToArray(final List a)
Converts a List to a regular double[]
final double[] x = new double[a.size()];
int i = 0;
for (double d : a)
    x[i++] = d;
return x;
Object[]listToArray(List data)
list To Array
Object newdata[] = new Object[data.size()];
int i = 0;
for (Iterator iterator = data.iterator(); iterator.hasNext();) {
    Object cur = iterator.next();
    newdata[i] = cur;
    i++;
return newdata;
...
long[]listToArray(List ids)
Converts the give list of Long objects to array.
long[] result = new long[ids.size()];
for (int i = 0; i < result.length; i++) {
    result[i] = ((Long) ids.get(i)).longValue();
return result;
Object[]listToArray(List list)
list To Array
return list.stream().toArray(Object[]::new);