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

char[]toCharArray(Object[] array)
to Char Array
final int s = array.length;
final char[] ret = new char[s];
for (int i = 0; i != s; ++i)
    ret[i] = (Character) array[i];
return ret;
boolean[]toPrimitive(Boolean[] array)

Converts an array of object Booleans to primitives.

This method returns null for a null input array.

if (array == null) {
    return null;
} else if (array.length == 0) {
    return EMPTY_BOOLEAN_ARRAY;
final boolean[] result = new boolean[array.length];
for (int i = 0; i < array.length; i++) {
    result[i] = array[i].booleanValue();
...
boolean[]toPrimitive(Boolean[] array, boolean valueForNull)

Converts an array of object Booleans 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_BOOLEAN_ARRAY;
final boolean[] result = new boolean[array.length];
for (int i = 0; i < array.length; i++) {
    Boolean b = array[i];
...
byte[]toPrimitive(Byte[] array)

Converts an array of object Bytes to primitives.

This method returns null for a null input array.

if (array == null) {
    return null;
} else if (array.length == 0) {
    return EMPTY_BYTE_ARRAY;
final byte[] result = new byte[array.length];
for (int i = 0; i < array.length; i++) {
    result[i] = array[i].byteValue();
...
byte[]toPrimitive(Byte[] array, byte valueForNull)

Converts an array of object Bytes 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_BYTE_ARRAY;
final byte[] result = new byte[array.length];
for (int i = 0; i < array.length; i++) {
    Byte b = array[i];
...
char[]toPrimitive(Character[] array)

Converts an array of object Characters to primitives.

This method returns null for a null input array.

if (array == null) {
    return null;
} else if (array.length == 0) {
    return EMPTY_CHAR_ARRAY;
final char[] result = new char[array.length];
for (int i = 0; i < array.length; i++) {
    result[i] = array[i].charValue();
...
char[]toPrimitive(Character[] array, char valueForNull)

Converts an array of object Character 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_CHAR_ARRAY;
final char[] result = new char[array.length];
for (int i = 0; i < array.length; i++) {
    Character b = array[i];
...
double[]toPrimitive(Double[] array)

Converts an array of object Doubles to primitives.

This method returns null for a null input array.

if (array == null) {
    return null;
} else if (array.length == 0) {
    return EMPTY_DOUBLE_ARRAY;
final double[] result = new double[array.length];
for (int i = 0; i < array.length; i++) {
    result[i] = array[i].doubleValue();
...
double[]toPrimitive(Double[] array, double valueForNull)

Converts an array of object Doubles 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_DOUBLE_ARRAY;
final double[] result = new double[array.length];
for (int i = 0; i < array.length; i++) {
    Double b = array[i];
...
float[]toPrimitive(Float[] array)

Converts an array of object Floats to primitives.

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++) {
    result[i] = array[i].floatValue();
...