Android Utililty Methods Array to Primitive Type Convert

List of utility methods to do Array to Primitive Type Convert

Description

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

Method

float[]toPrimitive(Float[] array, float valueForNull)

Converts an array of object Floats to primitives handling null.

This method returns null for a null input array.

if (array == null) {
    return null;
} else if (array.length == 0) {
    return EMPTY_FLOAT_ARRAY;
final float[] result = new float[array.length];
for (int i = 0; i < array.length; i++) {
    Float b = array[i];
...
int[]toPrimitive(Integer[] array)

Converts an array of object Integers to primitives.

This method returns null for a null input array.

if (array == null) {
    return null;
} else if (array.length == 0) {
    return EMPTY_INT_ARRAY;
final int[] result = new int[array.length];
for (int i = 0; i < array.length; i++) {
    result[i] = array[i].intValue();
...
int[]toPrimitive(Integer[] array, int valueForNull)

Converts an array of object Integer to primitives handling null.

This method returns null for a null input array.

if (array == null) {
    return null;
} else if (array.length == 0) {
    return EMPTY_INT_ARRAY;
final int[] result = new int[array.length];
for (int i = 0; i < array.length; i++) {
    Integer b = array[i];
...
long[]toPrimitive(Long[] array)

Converts an array of object Longs to primitives.

This method returns null for a null input array.

if (array == null) {
    return null;
} else if (array.length == 0) {
    return EMPTY_LONG_ARRAY;
final long[] result = new long[array.length];
for (int i = 0; i < array.length; i++) {
    result[i] = array[i].longValue();
...
long[]toPrimitive(Long[] array, long valueForNull)

Converts an array of object Long to primitives handling null.

This method returns null for a null input array.

if (array == null) {
    return null;
} else if (array.length == 0) {
    return EMPTY_LONG_ARRAY;
final long[] result = new long[array.length];
for (int i = 0; i < array.length; i++) {
    Long b = array[i];
...
short[]toPrimitive(Short[] array)

Converts an array of object Shorts to primitives.

This method returns null for a null input array.

if (array == null) {
    return null;
} else if (array.length == 0) {
    return EMPTY_SHORT_ARRAY;
final short[] result = new short[array.length];
for (int i = 0; i < array.length; i++) {
    result[i] = array[i].shortValue();
...
short[]toPrimitive(Short[] array, short valueForNull)

Converts an array of object Short to primitives handling null.

This method returns null for a null input array.

if (array == null) {
    return null;
} else if (array.length == 0) {
    return EMPTY_SHORT_ARRAY;
final short[] result = new short[array.length];
for (int i = 0; i < array.length; i++) {
    Short b = array[i];
...
double[]unwrap(Double[] value)
Converts an array of Double into an array of double .
if (value == null)
    return null;
double[] res = new double[value.length];
for (int i = 0; i < value.length; i++) {
    res[i] = value[i];
return res;
float[]unwrap(Float[] value)
Converts an array of Float into an array of float .
if (value == null)
    return null;
float[] res = new float[value.length];
for (int i = 0; i < value.length; i++) {
    res[i] = value[i];
return res;
int[]unwrap(Integer[] value)
Converts an array of Integer into an array of int .
if (value == null)
    return null;
int[] res = new int[value.length];
for (int i = 0; i < value.length; i++) {
    res[i] = value[i];
return res;