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

boolean[]addAll(boolean[] array1, boolean... 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);
boolean[] joinedArray = new boolean[array1.length + array2.length];
System.arraycopy(array1, 0, joinedArray, 0, array1.length);
System.arraycopy(array2, 0, joinedArray, array1.length,
...
byte[]addAll(byte[] array1, byte... 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);
byte[] joinedArray = new byte[array1.length + array2.length];
System.arraycopy(array1, 0, joinedArray, 0, array1.length);
System.arraycopy(array2, 0, joinedArray, array1.length,
...
char[]addAll(char[] array1, char... 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);
char[] joinedArray = new char[array1.length + array2.length];
System.arraycopy(array1, 0, joinedArray, 0, array1.length);
System.arraycopy(array2, 0, joinedArray, array1.length,
...
double[]addAll(double[] array1, double... 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);
double[] joinedArray = new double[array1.length + array2.length];
System.arraycopy(array1, 0, joinedArray, 0, array1.length);
System.arraycopy(array2, 0, joinedArray, array1.length,
...
float[]addAll(float[] array1, float... 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);
float[] joinedArray = new float[array1.length + array2.length];
System.arraycopy(array1, 0, joinedArray, 0, array1.length);
System.arraycopy(array2, 0, joinedArray, array1.length,
...
int[]addAll(int[] array1, int... 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);
int[] joinedArray = new int[array1.length + array2.length];
System.arraycopy(array1, 0, joinedArray, 0, array1.length);
System.arraycopy(array2, 0, joinedArray, array1.length,
...
long[]addAll(long[] array1, long... 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);
long[] joinedArray = new long[array1.length + array2.length];
System.arraycopy(array1, 0, joinedArray, 0, array1.length);
System.arraycopy(array2, 0, joinedArray, array1.length,
...
short[]addAll(short[] array1, short... 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);
short[] joinedArray = new short[array1.length + array2.length];
System.arraycopy(array1, 0, joinedArray, 0, array1.length);
System.arraycopy(array2, 0, joinedArray, array1.length,
...
String[]append(String[] original, String element)
append
if (original == null) {
    return new String[] { element };
} else {
    original = ensureLength(original, original.length + 1);
    original[original.length - 1] = element;
    return original;
T[]appendElement(Class kind, T[] array, T element)
append Element
final T[] result;
final int end;
if (array != null) {
    end = array.length;
    result = (T[]) Array.newInstance(kind, end + 1);
    System.arraycopy(array, 0, result, 0, end);
} else {
    end = 0;
...