Java Utililty Methods Array Convert to

List of utility methods to do Array Convert to

Description

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

Method

int[]toInt(Integer[] arr)
to Int
if (arr == null) {
    return null;
int[] ret = new int[arr.length];
for (int i = 0; i < arr.length; i++) {
    ret[i] = arr[i];
return ret;
...
int[]toIntArray(double[] a)
to Int Array
int[] res = new int[a.length];
for (int i = 0; i < a.length; i++) {
    res[i] = (int) a[i];
return res;
int[]toIntArray(Integer[] data)
to Int Array
int[] result = new int[data.length];
for (int i = 0; i < data.length; i++)
    result[i] = data[i].intValue();
return result;
Long[]toLongArray(int[] array)
to Long Array
Long[] newArray = new Long[array.length];
for (int i = 0; i < array.length; i++) {
    newArray[i] = (long) array[i];
return newArray;
long[]toLongArray(String[] array)
Converts a String array to a long array.
long[] newArray = new long[array.length];
for (int i = 0; i < array.length; i++) {
    if (array[i] == null) {
        throw new RuntimeException("Null value in position " + i);
    newArray[i] = Long.parseLong(array[i]);
return newArray;
...