Android Utililty Methods Array Create

List of utility methods to do Array Create

Description

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

Method

T[]emptyArray(Class kind)
Returns an empty array of the specified type.
if (kind == Object.class) {
    return (T[]) EMPTY;
int bucket = ((System.identityHashCode(kind) / 8) & 0x7FFFFFFF)
        % CACHE_SIZE;
Object cache = sCache[bucket];
if (cache == null || cache.getClass().getComponentType() != kind) {
    cache = Array.newInstance(kind, 0);
...
T[]emptyArray(Class kind)
Returns an empty array of the specified type.
if (kind == Object.class) {
    return (T[]) EMPTY;
int bucket = ((System.identityHashCode(kind) / 8) & 0x7FFFFFFF)
        % CACHE_SIZE;
Object cache = sCache[bucket];
if (cache == null || cache.getClass().getComponentType() != kind) {
    cache = Array.newInstance(kind, 0);
...
T[]emptyArray(Class kind)
empty Array
if (kind == Object.class) {
    return (T[]) EMPTY;
int bucket = (System.identityHashCode(kind) / 8 & 0x7FFFFFFF)
        % CACHE_SIZE;
Object cache = sCache[bucket];
if (cache == null || cache.getClass().getComponentType() != kind) {
    cache = Array.newInstance(kind, 0);
...
boolean[]nullToEmpty(boolean[] array)

Defensive programming technique to change a null reference to an empty one.

This method returns an empty array for a null input array.

As a memory optimizing technique an empty array passed in will be overridden with the empty public static references in this class.

if (array == null || array.length == 0) {
    return EMPTY_BOOLEAN_ARRAY;
return array;
byte[]nullToEmpty(byte[] array)

Defensive programming technique to change a null reference to an empty one.

This method returns an empty array for a null input array.

As a memory optimizing technique an empty array passed in will be overridden with the empty public static references in this class.

if (array == null || array.length == 0) {
    return EMPTY_BYTE_ARRAY;
return array;
Character[]nullToEmpty(Character[] array)

Defensive programming technique to change a null reference to an empty one.

This method returns an empty array for a null input array.

As a memory optimizing technique an empty array passed in will be overridden with the empty public static references in this class.

if (array == null || array.length == 0) {
    return EMPTY_CHARACTER_OBJECT_ARRAY;
return array;
double[]nullToEmpty(double[] array)

Defensive programming technique to change a null reference to an empty one.

This method returns an empty array for a null input array.

As a memory optimizing technique an empty array passed in will be overridden with the empty public static references in this class.

if (array == null || array.length == 0) {
    return EMPTY_DOUBLE_ARRAY;
return array;
float[]nullToEmpty(float[] array)

Defensive programming technique to change a null reference to an empty one.

This method returns an empty array for a null input array.

As a memory optimizing technique an empty array passed in will be overridden with the empty public static references in this class.

if (array == null || array.length == 0) {
    return EMPTY_FLOAT_ARRAY;
return array;
Integer[]nullToEmpty(Integer[] array)

Defensive programming technique to change a null reference to an empty one.

This method returns an empty array for a null input array.

As a memory optimizing technique an empty array passed in will be overridden with the empty public static references in this class.

if (array == null || array.length == 0) {
    return EMPTY_INTEGER_OBJECT_ARRAY;
return array;
long[]nullToEmpty(long[] array)

Defensive programming technique to change a null reference to an empty one.

This method returns an empty array for a null input array.

As a memory optimizing technique an empty array passed in will be overridden with the empty public static references in this class.

if (array == null || array.length == 0) {
    return EMPTY_LONG_ARRAY;
return array;