Android Utililty Methods Array Primitive to Object Convert

List of utility methods to do Array Primitive to Object Convert

Description

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

Method

Boolean[]toObject(boolean[] array)

Converts an array of primitive booleans to objects.

This method returns null for a null input array.

if (array == null) {
    return null;
} else if (array.length == 0) {
    return EMPTY_BOOLEAN_OBJECT_ARRAY;
final Boolean[] result = new Boolean[array.length];
for (int i = 0; i < array.length; i++) {
    result[i] = (array[i] ? Boolean.TRUE : Boolean.FALSE);
...
Byte[]toObject(byte[] array)

Converts an array of primitive bytes to objects.

This method returns null for a null input array.

if (array == null) {
    return null;
} else if (array.length == 0) {
    return EMPTY_BYTE_OBJECT_ARRAY;
final Byte[] result = new Byte[array.length];
for (int i = 0; i < array.length; i++) {
    result[i] = Byte.valueOf(array[i]);
...
Character[]toObject(char[] array)

Converts an array of primitive chars to objects.

This method returns null for a null input array.

if (array == null) {
    return null;
} else if (array.length == 0) {
    return EMPTY_CHARACTER_OBJECT_ARRAY;
final Character[] result = new Character[array.length];
for (int i = 0; i < array.length; i++) {
    result[i] = Character.valueOf(array[i]);
...
Double[]toObject(double[] array)

Converts an array of primitive doubles to objects.

This method returns null for a null input array.

if (array == null) {
    return null;
} else if (array.length == 0) {
    return EMPTY_DOUBLE_OBJECT_ARRAY;
final Double[] result = new Double[array.length];
for (int i = 0; i < array.length; i++) {
    result[i] = Double.valueOf(array[i]);
...
Float[]toObject(float[] array)

Converts an array of primitive floats to objects.

This method returns null for a null input array.

if (array == null) {
    return null;
} else if (array.length == 0) {
    return EMPTY_FLOAT_OBJECT_ARRAY;
final Float[] result = new Float[array.length];
for (int i = 0; i < array.length; i++) {
    result[i] = Float.valueOf(array[i]);
...
Integer[]toObject(int[] array)

Converts an array of primitive ints to objects.

This method returns null for a null input array.

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

Converts an array of primitive longs to objects.

This method returns null for a null input array.

if (array == null) {
    return null;
} else if (array.length == 0) {
    return EMPTY_LONG_OBJECT_ARRAY;
final Long[] result = new Long[array.length];
for (int i = 0; i < array.length; i++) {
    result[i] = Long.valueOf(array[i]);
...
Short[]toObject(short[] array)

Converts an array of primitive shorts to objects.

This method returns null for a null input array.

if (array == null) {
    return null;
} else if (array.length == 0) {
    return EMPTY_SHORT_OBJECT_ARRAY;
final Short[] result = new Short[array.length];
for (int i = 0; i < array.length; i++) {
    result[i] = Short.valueOf(array[i]);
...
Double[]wrap(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] = Double.valueOf(value[i]);
return res;
Float[]wrap(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] = Float.valueOf(value[i]);
return res;