Android Utililty Methods Array Add

List of utility methods to do Array Add

Description

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

Method

double[]add(double[] array, int index, double element)

Inserts the specified element at the specified position in the array.

return (double[]) add(array, index, Double.valueOf(element),
        Double.TYPE);
float[]add(float[] array, float element)

Copies the given array and adds the given element at the end of the new array.

The new array contains the same elements of the input array plus the given element in the last position.

float[] newArray = (float[]) copyArrayGrow1(array, Float.TYPE);
newArray[newArray.length - 1] = element;
return newArray;
float[]add(float[] array, int index, float element)

Inserts the specified element at the specified position in the array.

return (float[]) add(array, index, Float.valueOf(element),
        Float.TYPE);
int[]add(int[] array, int element)

Copies the given array and adds the given element at the end of the new array.

The new array contains the same elements of the input array plus the given element in the last position.

int[] newArray = (int[]) copyArrayGrow1(array, Integer.TYPE);
newArray[newArray.length - 1] = element;
return newArray;
int[]add(int[] array, int index, int element)

Inserts the specified element at the specified position in the array.

return (int[]) add(array, index, Integer.valueOf(element),
        Integer.TYPE);
long[]add(long[] array, int index, long element)

Inserts the specified element at the specified position in the array.

return (long[]) add(array, index, Long.valueOf(element), Long.TYPE);
long[]add(long[] array, long element)

Copies the given array and adds the given element at the end of the new array.

The new array contains the same elements of the input array plus the given element in the last position.

long[] newArray = (long[]) copyArrayGrow1(array, Long.TYPE);
newArray[newArray.length - 1] = element;
return newArray;
short[]add(short[] array, int index, short element)

Inserts the specified element at the specified position in the array.

return (short[]) add(array, index, Short.valueOf(element),
        Short.TYPE);
short[]add(short[] array, short element)

Copies the given array and adds the given element at the end of the new array.

The new array contains the same elements of the input array plus the given element in the last position.

short[] newArray = (short[]) copyArrayGrow1(array, Short.TYPE);
newArray[newArray.length - 1] = element;
return newArray;
T[]addAll(T[] array1, T... array2)

Adds all the elements of the given arrays into a new array.

The new array contains all of the element of array1 followed by all of the elements array2.

if (array1 == null) {
    return clone(array2);
} else if (array2 == null) {
    return clone(array1);
final Class<?> type1 = array1.getClass().getComponentType();
@SuppressWarnings("unchecked")
T[] joinedArray = (T[]) Array.newInstance(type1, array1.length
...