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[]toArray(List list)
Returns the given list as a String[].
return (String[]) list.toArray(new String[list.size()]);
String[]toArray(List list)
convert a Vector of String into a String[]
String[] result = new String[list.size()];
list.toArray(result);
return result;
String[]toArray(List list)
Returns the given list as a String[].
return (String[]) list.toArray(new String[list.size()]);
Object[]toArray(List list, Object array[], int start, int end)
to Array
return toArray(list, array, start, end, -1);
StringtoArray(List lista)
to Array
StringBuffer sb = new StringBuffer();
sb.append("[");
for (Iterator iterator = lista.iterator(); iterator.hasNext();) {
    Object object = (Object) iterator.next();
    sb.append(object.toString());
    if (iterator.hasNext())
        sb.append(",");
sb.append("]");
return sb.toString();
Object[]toArray(List list)
list to array
if (null == list || list.isEmpty()) {
    return null;
Object[] arr = new Object[list.size()];
for (int i = 0; i < list.size(); i++) {
    arr[i] = list.get(i);
return arr;
...
byte[]toArray(List data)
Convert a List to array of byte
if (data == null) {
    return null;
byte[] result = new byte[data.size()];
for (int i = 0; i < data.size(); i++) {
    result[i] = data.get(i).byteValue();
return result;
...
byte[]toArray(List list)
to Array
if (list == null) {
    return null;
byte[] array = new byte[list.size()];
int index = 0;
for (byte value : list) {
    array[index++] = value;
return array;
double[]toArray(List list)
to Array
return list.stream().mapToDouble(Double::valueOf).toArray();
double[]toArray(List list)
Method for turning a list of doubles to an array.
double[] values = new double[list.size()];
for (int i = 0; i < values.length; i++) {
    values[i] = list.get(i);
return values;