Android APIs
public class

Arrays

extends Object
java.lang.Object
   ↳ java.util.Arrays

Class Overview

Arrays contains static methods which operate on arrays.

Summary

Public Methods
static <T> List<T> asList(T... array)
Returns a List of the objects in the specified array.
static <T> int binarySearch(T[] array, int startIndex, int endIndex, T value, Comparator<? super T> comparator)
Performs a binary search for value in the ascending sorted array array, in the range specified by fromIndex (inclusive) and toIndex (exclusive), using comparator to compare elements.
static int binarySearch(byte[] array, int startIndex, int endIndex, byte value)
Performs a binary search for value in the ascending sorted array array, in the range specified by fromIndex (inclusive) and toIndex (exclusive).
static int binarySearch(long[] array, int startIndex, int endIndex, long value)
Performs a binary search for value in the ascending sorted array array, in the range specified by fromIndex (inclusive) and toIndex (exclusive).
static int binarySearch(long[] array, long value)
Performs a binary search for value in the ascending sorted array array.
static int binarySearch(char[] array, char value)
Performs a binary search for value in the ascending sorted array array.
static int binarySearch(short[] array, int startIndex, int endIndex, short value)
Performs a binary search for value in the ascending sorted array array, in the range specified by fromIndex (inclusive) and toIndex (exclusive).
static <T> int binarySearch(T[] array, T value, Comparator<? super T> comparator)
Performs a binary search for value in the ascending sorted array array, using comparator to compare elements.
static int binarySearch(char[] array, int startIndex, int endIndex, char value)
Performs a binary search for value in the ascending sorted array array, in the range specified by fromIndex (inclusive) and toIndex (exclusive).
static int binarySearch(short[] array, short value)
Performs a binary search for value in the ascending sorted array array.
static int binarySearch(Object[] array, int startIndex, int endIndex, Object value)
Performs a binary search for value in the ascending sorted array array, in the range specified by fromIndex (inclusive) and toIndex (exclusive).
static int binarySearch(byte[] array, byte value)
Performs a binary search for value in the ascending sorted array array.
static int binarySearch(double[] array, double value)
Performs a binary search for value in the ascending sorted array array.
static int binarySearch(double[] array, int startIndex, int endIndex, double value)
Performs a binary search for value in the ascending sorted array array, in the range specified by fromIndex (inclusive) and toIndex (exclusive).
static int binarySearch(float[] array, float value)
Performs a binary search for value in the ascending sorted array array.
static int binarySearch(int[] array, int value)
Performs a binary search for value in the ascending sorted array array.
static int binarySearch(float[] array, int startIndex, int endIndex, float value)
Performs a binary search for value in the ascending sorted array array, in the range specified by fromIndex (inclusive) and toIndex (exclusive).
static int binarySearch(Object[] array, Object value)
Performs a binary search for value in the ascending sorted array array.
static int binarySearch(int[] array, int startIndex, int endIndex, int value)
Performs a binary search for value in the ascending sorted array array, in the range specified by fromIndex (inclusive) and toIndex (exclusive).
static <T, U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> newType)
Copies newLength elements from original into a new array.
static short[] copyOf(short[] original, int newLength)
Copies newLength elements from original into a new array.
static long[] copyOf(long[] original, int newLength)
Copies newLength elements from original into a new array.
static double[] copyOf(double[] original, int newLength)
Copies newLength elements from original into a new array.
static boolean[] copyOf(boolean[] original, int newLength)
Copies newLength elements from original into a new array.
static char[] copyOf(char[] original, int newLength)
Copies newLength elements from original into a new array.
static int[] copyOf(int[] original, int newLength)
Copies newLength elements from original into a new array.
static float[] copyOf(float[] original, int newLength)
Copies newLength elements from original into a new array.
static byte[] copyOf(byte[] original, int newLength)
Copies newLength elements from original into a new array.
static <T> T[] copyOf(T[] original, int newLength)
Copies newLength elements from original into a new array.
static byte[] copyOfRange(byte[] original, int start, int end)
Copies elements from original into a new array, from indexes start (inclusive) to end (exclusive).
static <T> T[] copyOfRange(T[] original, int start, int end)
Copies elements from original into a new array, from indexes start (inclusive) to end (exclusive).
static <T, U> T[] copyOfRange(U[] original, int start, int end, Class<? extends T[]> newType)
Copies elements from original into a new array, from indexes start (inclusive) to end (exclusive).
static double[] copyOfRange(double[] original, int start, int end)
Copies elements from original into a new array, from indexes start (inclusive) to end (exclusive).
static int[] copyOfRange(int[] original, int start, int end)
Copies elements from original into a new array, from indexes start (inclusive) to end (exclusive).
static long[] copyOfRange(long[] original, int start, int end)
Copies elements from original into a new array, from indexes start (inclusive) to end (exclusive).
static boolean[] copyOfRange(boolean[] original, int start, int end)
Copies elements from original into a new array, from indexes start (inclusive) to end (exclusive).
static char[] copyOfRange(char[] original, int start, int end)
Copies elements from original into a new array, from indexes start (inclusive) to end (exclusive).
static short[] copyOfRange(short[] original, int start, int end)
Copies elements from original into a new array, from indexes start (inclusive) to end (exclusive).
static float[] copyOfRange(float[] original, int start, int end)
Copies elements from original into a new array, from indexes start (inclusive) to end (exclusive).
static boolean deepEquals(Object[] array1, Object[] array2)
Returns true if the two given arrays are deeply equal to one another.
static int deepHashCode(Object[] array)
Returns a hash code based on the "deep contents" of the given array.
static String deepToString(Object[] array)
Creates a "deep" String representation of the Object[] passed, such that if the array contains other arrays, the String representation of those arrays is generated as well.
static boolean equals(char[] array1, char[] array2)
Compares the two arrays.
static boolean equals(Object[] array1, Object[] array2)
Compares the two arrays.
static boolean equals(int[] array1, int[] array2)
Compares the two arrays.
static boolean equals(float[] array1, float[] array2)
Compares the two arrays.
static boolean equals(double[] array1, double[] array2)
Compares the two arrays.
static boolean equals(short[] array1, short[] array2)
Compares the two arrays.
static boolean equals(byte[] array1, byte[] array2)
Compares the two arrays.
static boolean equals(long[] array1, long[] array2)
Compares the two arrays.
static boolean equals(boolean[] array1, boolean[] array2)
Compares the two arrays.
static void fill(boolean[] array, int start, int end, boolean value)
Fills the specified range in the array with the specified element.
static void fill(int[] array, int value)
Fills the specified array with the specified element.
static void fill(int[] array, int start, int end, int value)
Fills the specified range in the array with the specified element.
static void fill(double[] array, int start, int end, double value)
Fills the specified range in the array with the specified element.
static void fill(char[] array, char value)
Fills the specified array with the specified element.
static void fill(float[] array, float value)
Fills the specified array with the specified element.
static void fill(char[] array, int start, int end, char value)
Fills the specified range in the array with the specified element.
static void fill(long[] array, long value)
Fills the specified array with the specified element.
static void fill(float[] array, int start, int end, float value)
Fills the specified range in the array with the specified element.
static void fill(Object[] array, int start, int end, Object value)
Fills the specified range in the array with the specified element.
static void fill(byte[] array, byte value)
Fills the specified array with the specified element.
static void fill(short[] array, int start, int end, short value)
Fills the specified range in the array with the specified element.
static void fill(byte[] array, int start, int end, byte value)
Fills the specified range in the array with the specified element.
static void fill(double[] array, double value)
Fills the specified array with the specified element.
static void fill(long[] array, int start, int end, long value)
Fills the specified range in the array with the specified element.
static void fill(boolean[] array, boolean value)
Fills the specified array with the specified element.
static void fill(short[] array, short value)
Fills the specified array with the specified element.
static void fill(Object[] array, Object value)
Fills the specified array with the specified element.
static int hashCode(boolean[] array)
Returns a hash code based on the contents of the given array.
static int hashCode(int[] array)
Returns a hash code based on the contents of the given array.
static int hashCode(Object[] array)
Returns a hash code based on the contents of the given array.
static int hashCode(double[] array)
Returns a hash code based on the contents of the given array.
static int hashCode(short[] array)
Returns a hash code based on the contents of the given array.
static int hashCode(byte[] array)
Returns a hash code based on the contents of the given array.
static int hashCode(char[] array)
Returns a hash code based on the contents of the given array.
static int hashCode(float[] array)
Returns a hash code based on the contents of the given array.
static int hashCode(long[] array)
Returns a hash code based on the contents of the given array.
static void sort(long[] array, int start, int end)
Sorts the specified range in the array in ascending numerical order.
static void sort(char[] array)
Sorts the specified array in ascending numerical order.
static void sort(int[] array, int start, int end)
Sorts the specified range in the array in ascending numerical order.
static <T> void sort(T[] array, Comparator<? super T> comparator)
Sorts the specified array using the specified Comparator.
static void sort(int[] array)
Sorts the specified array in ascending numerical order.
static void sort(Object[] array)
Sorts the specified array in ascending natural order.
static void sort(char[] array, int start, int end)
Sorts the specified range in the array in ascending numerical order.
static void sort(double[] array, int start, int end)
Sorts the specified range in the array in ascending numerical order.
static void sort(float[] array)
Sorts the specified array in ascending numerical order.
static <T> void sort(T[] array, int start, int end, Comparator<? super T> comparator)
Sorts the specified range in the array using the specified Comparator.
static void sort(byte[] array, int start, int end)
Sorts the specified range in the array in ascending numerical order.
static void sort(long[] array)
Sorts the specified array in ascending numerical order.
static void sort(float[] array, int start, int end)
Sorts the specified range in the array in ascending numerical order.
static void sort(short[] array, int start, int end)
Sorts the specified range in the array in ascending numerical order.
static void sort(byte[] array)
Sorts the specified array in ascending numerical order.
static void sort(short[] array)
Sorts the specified array in ascending numerical order.
static void sort(Object[] array, int start, int end)
Sorts the specified range in the array in ascending natural order.
static void sort(double[] array)
Sorts the specified array in ascending numerical order.
static String toString(long[] array)
Creates a String representation of the long[] passed.
static String toString(int[] array)
Creates a String representation of the int[] passed.
static String toString(char[] array)
Creates a String representation of the char[] passed.
static String toString(boolean[] array)
Creates a String representation of the boolean[] passed.
static String toString(byte[] array)
Creates a String representation of the byte[] passed.
static String toString(float[] array)
Creates a String representation of the float[] passed.
static String toString(short[] array)
Creates a String representation of the short[] passed.
static String toString(Object[] array)
Creates a String representation of the Object[] passed.
static String toString(double[] array)
Creates a String representation of the double[] passed.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static List<T> asList (T... array)

Added in API level 1

Returns a List of the objects in the specified array. The size of the List cannot be modified, i.e. adding and removing are unsupported, but the elements can be set. Setting an element modifies the underlying array.

Parameters
array T: the array.
Returns
List<T> a List of the elements of the specified array.

public static int binarySearch (T[] array, int startIndex, int endIndex, T value, Comparator<? super T> comparator)

Added in API level 9

Performs a binary search for value in the ascending sorted array array, in the range specified by fromIndex (inclusive) and toIndex (exclusive), using comparator to compare elements. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.

Parameters
array T: the sorted array to search.
startIndex int: the inclusive start index.
endIndex int: the exclusive start index.
value T: the element to find.
comparator Comparator: the Comparator used to compare the elements.
Returns
int the non-negative index of the element, or a negative index which is -index - 1 where the element would be inserted.
Throws
ClassCastException if an element in the array or the search element does not implement Comparable, or cannot be compared to each other.
IllegalArgumentException if startIndex > endIndex
ArrayIndexOutOfBoundsException if startIndex < 0 || endIndex > array.length

public static int binarySearch (byte[] array, int startIndex, int endIndex, byte value)

Added in API level 9

Performs a binary search for value in the ascending sorted array array, in the range specified by fromIndex (inclusive) and toIndex (exclusive). Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.

Parameters
array byte: the sorted array to search.
startIndex int: the inclusive start index.
endIndex int: the exclusive start index.
value byte: the element to find.
Returns
int the non-negative index of the element, or a negative index which is -index - 1 where the element would be inserted.
Throws
IllegalArgumentException if startIndex > endIndex
ArrayIndexOutOfBoundsException if startIndex < 0 || endIndex > array.length

public static int binarySearch (long[] array, int startIndex, int endIndex, long value)

Added in API level 9

Performs a binary search for value in the ascending sorted array array, in the range specified by fromIndex (inclusive) and toIndex (exclusive). Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.

Parameters
array long: the sorted array to search.
startIndex int: the inclusive start index.
endIndex int: the exclusive start index.
value long: the element to find.
Returns
int the non-negative index of the element, or a negative index which is -index - 1 where the element would be inserted.
Throws
IllegalArgumentException if startIndex > endIndex
ArrayIndexOutOfBoundsException if startIndex < 0 || endIndex > array.length

public static int binarySearch (long[] array, long value)

Added in API level 1

Performs a binary search for value in the ascending sorted array array. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.

Parameters
array long: the sorted array to search.
value long: the element to find.
Returns
int the non-negative index of the element, or a negative index which is -index - 1 where the element would be inserted.

public static int binarySearch (char[] array, char value)

Added in API level 1

Performs a binary search for value in the ascending sorted array array. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.

Parameters
array char: the sorted array to search.
value char: the element to find.
Returns
int the non-negative index of the element, or a negative index which is -index - 1 where the element would be inserted.

public static int binarySearch (short[] array, int startIndex, int endIndex, short value)

Added in API level 9

Performs a binary search for value in the ascending sorted array array, in the range specified by fromIndex (inclusive) and toIndex (exclusive). Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.

Parameters
array short: the sorted array to search.
startIndex int: the inclusive start index.
endIndex int: the exclusive start index.
value short: the element to find.
Returns
int the non-negative index of the element, or a negative index which is -index - 1 where the element would be inserted.
Throws
IllegalArgumentException if startIndex > endIndex
ArrayIndexOutOfBoundsException if startIndex < 0 || endIndex > array.length

public static int binarySearch (T[] array, T value, Comparator<? super T> comparator)

Added in API level 1

Performs a binary search for value in the ascending sorted array array, using comparator to compare elements. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.

Parameters
array T: the sorted array to search.
value T: the element to find.
comparator Comparator: the Comparator used to compare the elements.
Returns
int the non-negative index of the element, or a negative index which is -index - 1 where the element would be inserted.
Throws
ClassCastException if an element in the array or the search element does not implement Comparable, or cannot be compared to each other.

public static int binarySearch (char[] array, int startIndex, int endIndex, char value)

Added in API level 9

Performs a binary search for value in the ascending sorted array array, in the range specified by fromIndex (inclusive) and toIndex (exclusive). Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.

Parameters
array char: the sorted array to search.
startIndex int: the inclusive start index.
endIndex int: the exclusive start index.
value char: the element to find.
Returns
int the non-negative index of the element, or a negative index which is -index - 1 where the element would be inserted.
Throws
IllegalArgumentException if startIndex > endIndex
ArrayIndexOutOfBoundsException if startIndex < 0 || endIndex > array.length

public static int binarySearch (short[] array, short value)

Added in API level 1

Performs a binary search for value in the ascending sorted array array. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.

Parameters
array short: the sorted array to search.
value short: the element to find.
Returns
int the non-negative index of the element, or a negative index which is -index - 1 where the element would be inserted.

public static int binarySearch (Object[] array, int startIndex, int endIndex, Object value)

Added in API level 9

Performs a binary search for value in the ascending sorted array array, in the range specified by fromIndex (inclusive) and toIndex (exclusive). Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.

Parameters
array Object: the sorted array to search.
startIndex int: the inclusive start index.
endIndex int: the exclusive start index.
value Object: the element to find.
Returns
int the non-negative index of the element, or a negative index which is -index - 1 where the element would be inserted.
Throws
ClassCastException if an element in the array or the search element does not implement Comparable, or cannot be compared to each other.
IllegalArgumentException if startIndex > endIndex
ArrayIndexOutOfBoundsException if startIndex < 0 || endIndex > array.length

public static int binarySearch (byte[] array, byte value)

Added in API level 1

Performs a binary search for value in the ascending sorted array array. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.

Parameters
array byte: the sorted array to search.
value byte: the element to find.
Returns
int the non-negative index of the element, or a negative index which is -index - 1 where the element would be inserted.

public static int binarySearch (double[] array, double value)

Added in API level 1

Performs a binary search for value in the ascending sorted array array. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.

Parameters
array double: the sorted array to search.
value double: the element to find.
Returns
int the non-negative index of the element, or a negative index which is -index - 1 where the element would be inserted.

public static int binarySearch (double[] array, int startIndex, int endIndex, double value)

Added in API level 9

Performs a binary search for value in the ascending sorted array array, in the range specified by fromIndex (inclusive) and toIndex (exclusive). Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.

Parameters
array double: the sorted array to search.
startIndex int: the inclusive start index.
endIndex int: the exclusive start index.
value double: the element to find.
Returns
int the non-negative index of the element, or a negative index which is -index - 1 where the element would be inserted.
Throws
IllegalArgumentException if startIndex > endIndex
ArrayIndexOutOfBoundsException if startIndex < 0 || endIndex > array.length

public static int binarySearch (float[] array, float value)

Added in API level 1

Performs a binary search for value in the ascending sorted array array. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.

Parameters
array float: the sorted array to search.
value float: the element to find.
Returns
int the non-negative index of the element, or a negative index which is -index - 1 where the element would be inserted.

public static int binarySearch (int[] array, int value)

Added in API level 1

Performs a binary search for value in the ascending sorted array array. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.

Parameters
array int: the sorted array to search.
value int: the element to find.
Returns
int the non-negative index of the element, or a negative index which is -index - 1 where the element would be inserted.

public static int binarySearch (float[] array, int startIndex, int endIndex, float value)

Added in API level 9

Performs a binary search for value in the ascending sorted array array, in the range specified by fromIndex (inclusive) and toIndex (exclusive). Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.

Parameters
array float: the sorted array to search.
startIndex int: the inclusive start index.
endIndex int: the exclusive start index.
value float: the element to find.
Returns
int the non-negative index of the element, or a negative index which is -index - 1 where the element would be inserted.
Throws
IllegalArgumentException if startIndex > endIndex
ArrayIndexOutOfBoundsException if startIndex < 0 || endIndex > array.length

public static int binarySearch (Object[] array, Object value)

Added in API level 1

Performs a binary search for value in the ascending sorted array array. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.

Parameters
array Object: the sorted array to search.
value Object: the element to find.
Returns
int the non-negative index of the element, or a negative index which is -index - 1 where the element would be inserted.
Throws
ClassCastException if an element in the array or the search element does not implement Comparable, or cannot be compared to each other.

public static int binarySearch (int[] array, int startIndex, int endIndex, int value)

Added in API level 9

Performs a binary search for value in the ascending sorted array array, in the range specified by fromIndex (inclusive) and toIndex (exclusive). Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.

Parameters
array int: the sorted array to search.
startIndex int: the inclusive start index.
endIndex int: the exclusive start index.
value int: the element to find.
Returns
int the non-negative index of the element, or a negative index which is -index - 1 where the element would be inserted.
Throws
IllegalArgumentException if startIndex > endIndex
ArrayIndexOutOfBoundsException if startIndex < 0 || endIndex > array.length

public static T[] copyOf (U[] original, int newLength, Class<? extends T[]> newType)

Added in API level 9

Copies newLength elements from original into a new array. If newLength is greater than original.length, the result is padded with the value null.

Parameters
original U: the original array
newLength int: the length of the new array
newType Class: the class of the new array
Returns
T[] the new array
Throws
NegativeArraySizeException if newLength < 0
NullPointerException if original == null
ArrayStoreException if a value in original is incompatible with T

public static short[] copyOf (short[] original, int newLength)

Added in API level 9

Copies newLength elements from original into a new array. If newLength is greater than original.length, the result is padded with the value (short) 0.

Parameters
original short: the original array
newLength int: the length of the new array
Returns
short[] the new array
Throws
NegativeArraySizeException if newLength < 0
NullPointerException if original == null

public static long[] copyOf (long[] original, int newLength)

Added in API level 9

Copies newLength elements from original into a new array. If newLength is greater than original.length, the result is padded with the value 0L.

Parameters
original long: the original array
newLength int: the length of the new array
Returns
long[] the new array
Throws
NegativeArraySizeException if newLength < 0
NullPointerException if original == null

public static double[] copyOf (double[] original, int newLength)

Added in API level 9

Copies newLength elements from original into a new array. If newLength is greater than original.length, the result is padded with the value 0.0d.

Parameters
original double: the original array
newLength int: the length of the new array
Returns
double[] the new array
Throws
NegativeArraySizeException if newLength < 0
NullPointerException if original == null

public static boolean[] copyOf (boolean[] original, int newLength)

Added in API level 9

Copies newLength elements from original into a new array. If newLength is greater than original.length, the result is padded with the value false.

Parameters
original boolean: the original array
newLength int: the length of the new array
Returns
boolean[] the new array
Throws
NegativeArraySizeException if newLength < 0
NullPointerException if original == null

public static char[] copyOf (char[] original, int newLength)

Added in API level 9

Copies newLength elements from original into a new array. If newLength is greater than original.length, the result is padded with the value '\\u0000'.

Parameters
original char: the original array
newLength int: the length of the new array
Returns
char[] the new array
Throws
NegativeArraySizeException if newLength < 0
NullPointerException if original == null

public static int[] copyOf (int[] original, int newLength)

Added in API level 9

Copies newLength elements from original into a new array. If newLength is greater than original.length, the result is padded with the value 0.

Parameters
original int: the original array
newLength int: the length of the new array
Returns
int[] the new array
Throws
NegativeArraySizeException if newLength < 0
NullPointerException if original == null

public static float[] copyOf (float[] original, int newLength)

Added in API level 9

Copies newLength elements from original into a new array. If newLength is greater than original.length, the result is padded with the value 0.0f.

Parameters
original float: the original array
newLength int: the length of the new array
Returns
float[] the new array
Throws
NegativeArraySizeException if newLength < 0
NullPointerException if original == null

public static byte[] copyOf (byte[] original, int newLength)

Added in API level 9

Copies newLength elements from original into a new array. If newLength is greater than original.length, the result is padded with the value (byte) 0.

Parameters
original byte: the original array
newLength int: the length of the new array
Returns
byte[] the new array
Throws
NegativeArraySizeException if newLength < 0
NullPointerException if original == null

public static T[] copyOf (T[] original, int newLength)

Added in API level 9

Copies newLength elements from original into a new array. If newLength is greater than original.length, the result is padded with the value null.

Parameters
original T: the original array
newLength int: the length of the new array
Returns
T[] the new array
Throws
NegativeArraySizeException if newLength < 0
NullPointerException if original == null

public static byte[] copyOfRange (byte[] original, int start, int end)

Added in API level 9

Copies elements from original into a new array, from indexes start (inclusive) to end (exclusive). The original order of elements is preserved. If end is greater than original.length, the result is padded with the value (byte) 0.

Parameters
original byte: the original array
start int: the start index, inclusive
end int: the end index, exclusive
Returns
byte[] the new array
Throws
ArrayIndexOutOfBoundsException if start < 0 || start > original.length
IllegalArgumentException if start > end
NullPointerException if original == null

public static T[] copyOfRange (T[] original, int start, int end)

Added in API level 9

Copies elements from original into a new array, from indexes start (inclusive) to end (exclusive). The original order of elements is preserved. If end is greater than original.length, the result is padded with the value null.

Parameters
original T: the original array
start int: the start index, inclusive
end int: the end index, exclusive
Returns
T[] the new array
Throws
ArrayIndexOutOfBoundsException if start < 0 || start > original.length
IllegalArgumentException if start > end
NullPointerException if original == null

public static T[] copyOfRange (U[] original, int start, int end, Class<? extends T[]> newType)

Added in API level 9

Copies elements from original into a new array, from indexes start (inclusive) to end (exclusive). The original order of elements is preserved. If end is greater than original.length, the result is padded with the value null.

Parameters
original U: the original array
start int: the start index, inclusive
end int: the end index, exclusive
newType Class
Returns
T[] the new array
Throws
ArrayIndexOutOfBoundsException if start < 0 || start > original.length
IllegalArgumentException if start > end
NullPointerException if original == null
ArrayStoreException if a value in original is incompatible with T

public static double[] copyOfRange (double[] original, int start, int end)

Added in API level 9

Copies elements from original into a new array, from indexes start (inclusive) to end (exclusive). The original order of elements is preserved. If end is greater than original.length, the result is padded with the value 0.0d.

Parameters
original double: the original array
start int: the start index, inclusive
end int: the end index, exclusive
Returns
double[] the new array
Throws
ArrayIndexOutOfBoundsException if start < 0 || start > original.length
IllegalArgumentException if start > end
NullPointerException if original == null

public static int[] copyOfRange (int[] original, int start, int end)

Added in API level 9

Copies elements from original into a new array, from indexes start (inclusive) to end (exclusive). The original order of elements is preserved. If end is greater than original.length, the result is padded with the value 0.

Parameters
original int: the original array
start int: the start index, inclusive
end int: the end index, exclusive
Returns
int[] the new array
Throws
ArrayIndexOutOfBoundsException if start < 0 || start > original.length
IllegalArgumentException if start > end
NullPointerException if original == null

public static long[] copyOfRange (long[] original, int start, int end)

Added in API level 9

Copies elements from original into a new array, from indexes start (inclusive) to end (exclusive). The original order of elements is preserved. If end is greater than original.length, the result is padded with the value 0L.

Parameters
original long: the original array
start int: the start index, inclusive
end int: the end index, exclusive
Returns
long[] the new array
Throws
ArrayIndexOutOfBoundsException if start < 0 || start > original.length
IllegalArgumentException if start > end
NullPointerException if original == null

public static boolean[] copyOfRange (boolean[] original, int start, int end)

Added in API level 9

Copies elements from original into a new array, from indexes start (inclusive) to end (exclusive). The original order of elements is preserved. If end is greater than original.length, the result is padded with the value false.

Parameters
original boolean: the original array
start int: the start index, inclusive
end int: the end index, exclusive
Returns
boolean[] the new array
Throws
ArrayIndexOutOfBoundsException if start < 0 || start > original.length
IllegalArgumentException if start > end
NullPointerException if original == null

public static char[] copyOfRange (char[] original, int start, int end)

Added in API level 9

Copies elements from original into a new array, from indexes start (inclusive) to end (exclusive). The original order of elements is preserved. If end is greater than original.length, the result is padded with the value '\\u0000'.

Parameters
original char: the original array
start int: the start index, inclusive
end int: the end index, exclusive
Returns
char[] the new array
Throws
ArrayIndexOutOfBoundsException if start < 0 || start > original.length
IllegalArgumentException if start > end
NullPointerException if original == null

public static short[] copyOfRange (short[] original, int start, int end)

Added in API level 9

Copies elements from original into a new array, from indexes start (inclusive) to end (exclusive). The original order of elements is preserved. If end is greater than original.length, the result is padded with the value (short) 0.

Parameters
original short: the original array
start int: the start index, inclusive
end int: the end index, exclusive
Returns
short[] the new array
Throws
ArrayIndexOutOfBoundsException if start < 0 || start > original.length
IllegalArgumentException if start > end
NullPointerException if original == null

public static float[] copyOfRange (float[] original, int start, int end)

Added in API level 9

Copies elements from original into a new array, from indexes start (inclusive) to end (exclusive). The original order of elements is preserved. If end is greater than original.length, the result is padded with the value 0.0f.

Parameters
original float: the original array
start int: the start index, inclusive
end int: the end index, exclusive
Returns
float[] the new array
Throws
ArrayIndexOutOfBoundsException if start < 0 || start > original.length
IllegalArgumentException if start > end
NullPointerException if original == null

public static boolean deepEquals (Object[] array1, Object[] array2)

Added in API level 1

Returns true if the two given arrays are deeply equal to one another. Unlike the method equals(Object[] array1, Object[] array2), this method is appropriate for use for nested arrays of arbitrary depth.

Two array references are considered deeply equal if they are both null, or if they refer to arrays that have the same length and the elements at each index in the two arrays are equal.

Two null elements element1 and element2 are possibly deeply equal if any of the following conditions satisfied:

element1 and element2 are both arrays of object reference types, and Arrays.deepEquals(element1, element2) would return true.

element1 and element2 are arrays of the same primitive type, and the appropriate overloading of Arrays.equals(element1, element2) would return true.

element1 == element2

element1.equals(element2) would return true.

Note that this definition permits null elements at any depth.

If either of the given arrays contain themselves as elements, the behavior of this method is uncertain.

Parameters
array1 Object: the first Object array.
array2 Object: the second Object array.
Returns
boolean true if both arrays are null or if the arrays have the same length and the elements at each index in the two arrays are equal according to equals(), false otherwise.

public static int deepHashCode (Object[] array)

Added in API level 1

Returns a hash code based on the "deep contents" of the given array. If the array contains other arrays as its elements, the hash code is based on their contents not their identities. So it is not acceptable to invoke this method on an array that contains itself as an element, either directly or indirectly.

For any two arrays a and b, if Arrays.deepEquals(a, b) returns true, it means that the return value of Arrays.deepHashCode(a) equals Arrays.deepHashCode(b).

The computation of the value returned by this method is similar to that of the value returned by hashCode() invoked on a List containing a sequence of instances representing the elements of array in the same order. The difference is: If an element e of array is itself an array, its hash code is computed by calling the appropriate overloading of Arrays.hashCode(e) if e is an array of a primitive type, or by calling Arrays.deepHashCode(e) recursively if e is an array of a reference type. The value returned by this method is the same value as the method Arrays.asList(array).hashCode(). If the array is null, the return value is 0.

Parameters
array Object: the array whose hash code to compute.
Returns
int the hash code for array.

public static String deepToString (Object[] array)

Added in API level 1

Creates a "deep" String representation of the Object[] passed, such that if the array contains other arrays, the String representation of those arrays is generated as well.

If any of the elements are primitive arrays, the generation is delegated to the other toString methods in this class. If any element contains a reference to the original array, then it will be represented as "[...]". If an element is an Object[], then its representation is generated by a recursive call to this method. All other elements are converted via the valueOf(Object) method.

Parameters
array Object: the Object array to convert.
Returns
String the String representation of array.

public static boolean equals (char[] array1, char[] array2)

Added in API level 1

Compares the two arrays.

Parameters
array1 char: the first char array.
array2 char: the second char array.
Returns
boolean true if both arrays are null or if the arrays have the same length and the elements at each index in the two arrays are equal, false otherwise.

public static boolean equals (Object[] array1, Object[] array2)

Added in API level 1

Compares the two arrays.

Parameters
array1 Object: the first Object array.
array2 Object: the second Object array.
Returns
boolean true if both arrays are null or if the arrays have the same length and the elements at each index in the two arrays are equal according to equals(), false otherwise.

public static boolean equals (int[] array1, int[] array2)

Added in API level 1

Compares the two arrays.

Parameters
array1 int: the first int array.
array2 int: the second int array.
Returns
boolean true if both arrays are null or if the arrays have the same length and the elements at each index in the two arrays are equal, false otherwise.

public static boolean equals (float[] array1, float[] array2)

Added in API level 1

Compares the two arrays. The values are compared in the same manner as Float.equals().

Parameters
array1 float: the first float array.
array2 float: the second float array.
Returns
boolean true if both arrays are null or if the arrays have the same length and the elements at each index in the two arrays are equal, false otherwise.

See also:

public static boolean equals (double[] array1, double[] array2)

Added in API level 1

Compares the two arrays. The values are compared in the same manner as Double.equals().

Parameters
array1 double: the first double array.
array2 double: the second double array.
Returns
boolean true if both arrays are null or if the arrays have the same length and the elements at each index in the two arrays are equal, false otherwise.

See also:

public static boolean equals (short[] array1, short[] array2)

Added in API level 1

Compares the two arrays.

Parameters
array1 short: the first short array.
array2 short: the second short array.
Returns
boolean true if both arrays are null or if the arrays have the same length and the elements at each index in the two arrays are equal, false otherwise.

public static boolean equals (byte[] array1, byte[] array2)

Added in API level 1

Compares the two arrays.

Parameters
array1 byte: the first byte array.
array2 byte: the second byte array.
Returns
boolean true if both arrays are null or if the arrays have the same length and the elements at each index in the two arrays are equal, false otherwise.

public static boolean equals (long[] array1, long[] array2)

Added in API level 1

Compares the two arrays.

Parameters
array1 long: the first long array.
array2 long: the second long array.
Returns
boolean true if both arrays are null or if the arrays have the same length and the elements at each index in the two arrays are equal, false otherwise.

public static boolean equals (boolean[] array1, boolean[] array2)

Added in API level 1

Compares the two arrays.

Parameters
array1 boolean: the first boolean array.
array2 boolean: the second boolean array.
Returns
boolean true if both arrays are null or if the arrays have the same length and the elements at each index in the two arrays are equal, false otherwise.

public static void fill (boolean[] array, int start, int end, boolean value)

Added in API level 1

Fills the specified range in the array with the specified element.

Parameters
array boolean: the boolean array to fill.
start int: the first index to fill.
end int: the last + 1 index to fill.
value boolean: the boolean element.
Throws
IllegalArgumentException if start > end.
ArrayIndexOutOfBoundsException if start < 0 or end > array.length.

public static void fill (int[] array, int value)

Added in API level 1

Fills the specified array with the specified element.

Parameters
array int: the int array to fill.
value int: the int element.

public static void fill (int[] array, int start, int end, int value)

Added in API level 1

Fills the specified range in the array with the specified element.

Parameters
array int: the int array to fill.
start int: the first index to fill.
end int: the last + 1 index to fill.
value int: the int element.
Throws
IllegalArgumentException if start > end.
ArrayIndexOutOfBoundsException if start < 0 or end > array.length.

public static void fill (double[] array, int start, int end, double value)

Added in API level 1

Fills the specified range in the array with the specified element.

Parameters
array double: the double array to fill.
start int: the first index to fill.
end int: the last + 1 index to fill.
value double: the double element.
Throws
IllegalArgumentException if start > end.
ArrayIndexOutOfBoundsException if start < 0 or end > array.length.

public static void fill (char[] array, char value)

Added in API level 1

Fills the specified array with the specified element.

Parameters
array char: the char array to fill.
value char: the char element.

public static void fill (float[] array, float value)

Added in API level 1

Fills the specified array with the specified element.

Parameters
array float: the float array to fill.
value float: the float element.

public static void fill (char[] array, int start, int end, char value)

Added in API level 1

Fills the specified range in the array with the specified element.

Parameters
array char: the char array to fill.
start int: the first index to fill.
end int: the last + 1 index to fill.
value char: the char element.
Throws
IllegalArgumentException if start > end.
ArrayIndexOutOfBoundsException if start < 0 or end > array.length.

public static void fill (long[] array, long value)

Added in API level 1

Fills the specified array with the specified element.

Parameters
array long: the long array to fill.
value long: the long element.

public static void fill (float[] array, int start, int end, float value)

Added in API level 1

Fills the specified range in the array with the specified element.

Parameters
array float: the float array to fill.
start int: the first index to fill.
end int: the last + 1 index to fill.
value float: the float element.
Throws
IllegalArgumentException if start > end.
ArrayIndexOutOfBoundsException if start < 0 or end > array.length.

public static void fill (Object[] array, int start, int end, Object value)

Added in API level 1

Fills the specified range in the array with the specified element.

Parameters
array Object: the Object array to fill.
start int: the first index to fill.
end int: the last + 1 index to fill.
value Object: the Object element.
Throws
IllegalArgumentException if start > end.
ArrayIndexOutOfBoundsException if start < 0 or end > array.length.

public static void fill (byte[] array, byte value)

Added in API level 1

Fills the specified array with the specified element.

Parameters
array byte: the byte array to fill.
value byte: the byte element.

public static void fill (short[] array, int start, int end, short value)

Added in API level 1

Fills the specified range in the array with the specified element.

Parameters
array short: the short array to fill.
start int: the first index to fill.
end int: the last + 1 index to fill.
value short: the short element.
Throws
IllegalArgumentException if start > end.
ArrayIndexOutOfBoundsException if start < 0 or end > array.length.

public static void fill (byte[] array, int start, int end, byte value)

Added in API level 1

Fills the specified range in the array with the specified element.

Parameters
array byte: the byte array to fill.
start int: the first index to fill.
end int: the last + 1 index to fill.
value byte: the byte element.
Throws
IllegalArgumentException if start > end.
ArrayIndexOutOfBoundsException if start < 0 or end > array.length.

public static void fill (double[] array, double value)

Added in API level 1

Fills the specified array with the specified element.

Parameters
array double: the double array to fill.
value double: the double element.

public static void fill (long[] array, int start, int end, long value)

Added in API level 1

Fills the specified range in the array with the specified element.

Parameters
array long: the long array to fill.
start int: the first index to fill.
end int: the last + 1 index to fill.
value long: the long element.
Throws
IllegalArgumentException if start > end.
ArrayIndexOutOfBoundsException if start < 0 or end > array.length.

public static void fill (boolean[] array, boolean value)

Added in API level 1

Fills the specified array with the specified element.

Parameters
array boolean: the boolean array to fill.
value boolean: the boolean element.

public static void fill (short[] array, short value)

Added in API level 1

Fills the specified array with the specified element.

Parameters
array short: the short array to fill.
value short: the short element.

public static void fill (Object[] array, Object value)

Added in API level 1

Fills the specified array with the specified element.

Parameters
array Object: the Object array to fill.
value Object: the Object element.

public static int hashCode (boolean[] array)

Added in API level 1

Returns a hash code based on the contents of the given array. For any two boolean arrays a and b, if Arrays.equals(a, b) returns true, it means that the return value of Arrays.hashCode(a) equals Arrays.hashCode(b).

The value returned by this method is the same value as the hashCode() method which is invoked on a List containing a sequence of Boolean instances representing the elements of array in the same order. If the array is null, the return value is 0.

Parameters
array boolean: the array whose hash code to compute.
Returns
int the hash code for array.

public static int hashCode (int[] array)

Added in API level 1

Returns a hash code based on the contents of the given array. For any two not-null int arrays a and b, if Arrays.equals(a, b) returns true, it means that the return value of Arrays.hashCode(a) equals Arrays.hashCode(b).

The value returned by this method is the same value as the hashCode() method which is invoked on a List containing a sequence of Integer instances representing the elements of array in the same order. If the array is null, the return value is 0.

Parameters
array int: the array whose hash code to compute.
Returns
int the hash code for array.

public static int hashCode (Object[] array)

Added in API level 1

Returns a hash code based on the contents of the given array. If the array contains other arrays as its elements, the hash code is based on their identities not their contents. So it is acceptable to invoke this method on an array that contains itself as an element, either directly or indirectly.

For any two arrays a and b, if Arrays.equals(a, b) returns true, it means that the return value of Arrays.hashCode(a) equals Arrays.hashCode(b).

The value returned by this method is the same value as the method Arrays.asList(array).hashCode(). If the array is null, the return value is 0.

Parameters
array Object: the array whose hash code to compute.
Returns
int the hash code for array.

public static int hashCode (double[] array)

Added in API level 1

Returns a hash code based on the contents of the given array. For any two double arrays a and b, if Arrays.equals(a, b) returns true, it means that the return value of Arrays.hashCode(a) equals Arrays.hashCode(b).

The value returned by this method is the same value as the hashCode() method which is invoked on a List containing a sequence of Double instances representing the elements of array in the same order. If the array is null, the return value is 0.

Parameters
array double: the array whose hash code to compute.
Returns
int the hash code for array.

public static int hashCode (short[] array)

Added in API level 1

Returns a hash code based on the contents of the given array. For any two short arrays a and b, if Arrays.equals(a, b) returns true, it means that the return value of Arrays.hashCode(a) equals Arrays.hashCode(b).

The value returned by this method is the same value as the hashCode() method which is invoked on a List containing a sequence of Short instances representing the elements of array in the same order. If the array is null, the return value is 0.

Parameters
array short: the array whose hash code to compute.
Returns
int the hash code for array.

public static int hashCode (byte[] array)

Added in API level 1

Returns a hash code based on the contents of the given array. For any two byte arrays a and b, if Arrays.equals(a, b) returns true, it means that the return value of Arrays.hashCode(a) equals Arrays.hashCode(b).

The value returned by this method is the same value as the hashCode() method which is invoked on a List containing a sequence of Byte instances representing the elements of array in the same order. If the array is null, the return value is 0.

Parameters
array byte: the array whose hash code to compute.
Returns
int the hash code for array.

public static int hashCode (char[] array)

Added in API level 1

Returns a hash code based on the contents of the given array. For any two char arrays a and b, if Arrays.equals(a, b) returns true, it means that the return value of Arrays.hashCode(a) equals Arrays.hashCode(b).

The value returned by this method is the same value as the hashCode() method which is invoked on a List containing a sequence of Character instances representing the elements of array in the same order. If the array is null, the return value is 0.

Parameters
array char: the array whose hash code to compute.
Returns
int the hash code for array.

public static int hashCode (float[] array)

Added in API level 1

Returns a hash code based on the contents of the given array. For any two float arrays a and b, if Arrays.equals(a, b) returns true, it means that the return value of Arrays.hashCode(a) equals Arrays.hashCode(b).

The value returned by this method is the same value as the hashCode() method which is invoked on a List containing a sequence of Float instances representing the elements of array in the same order. If the array is null, the return value is 0.

Parameters
array float: the array whose hash code to compute.
Returns
int the hash code for array.

public static int hashCode (long[] array)

Added in API level 1

Returns a hash code based on the contents of the given array. For any two long arrays a and b, if Arrays.equals(a, b) returns true, it means that the return value of Arrays.hashCode(a) equals Arrays.hashCode(b).

The value returned by this method is the same value as the hashCode() method which is invoked on a List containing a sequence of Long instances representing the elements of array in the same order. If the array is null, the return value is 0.

Parameters
array long: the array whose hash code to compute.
Returns
int the hash code for array.

public static void sort (long[] array, int start, int end)

Added in API level 1

Sorts the specified range in the array in ascending numerical order.

Parameters
array long: the long array to be sorted.
start int: the start index to sort.
end int: the last + 1 index to sort.
Throws
IllegalArgumentException if start > end.
ArrayIndexOutOfBoundsException if start < 0 or end > array.length.

public static void sort (char[] array)

Added in API level 1

Sorts the specified array in ascending numerical order.

Parameters
array char: the char array to be sorted.

public static void sort (int[] array, int start, int end)

Added in API level 1

Sorts the specified range in the array in ascending numerical order.

Parameters
array int: the int array to be sorted.
start int: the start index to sort.
end int: the last + 1 index to sort.
Throws
IllegalArgumentException if start > end.
ArrayIndexOutOfBoundsException if start < 0 or end > array.length.

public static void sort (T[] array, Comparator<? super T> comparator)

Added in API level 1

Sorts the specified array using the specified Comparator. All elements must be comparable to each other without a ClassCastException being thrown.

Parameters
array T
comparator Comparator
Throws
ClassCastException if elements in the array cannot be compared to each other using the Comparator.

public static void sort (int[] array)

Added in API level 1

Sorts the specified array in ascending numerical order.

Parameters
array int: the int array to be sorted.

public static void sort (Object[] array)

Added in API level 1

Sorts the specified array in ascending natural order.

Parameters
array Object
Throws
ClassCastException if any element does not implement Comparable, or if compareTo throws for any pair of elements.

public static void sort (char[] array, int start, int end)

Added in API level 1

Sorts the specified range in the array in ascending numerical order.

Parameters
array char: the char array to be sorted.
start int: the start index to sort.
end int: the last + 1 index to sort.
Throws
IllegalArgumentException if start > end.
ArrayIndexOutOfBoundsException if start < 0 or end > array.length.

public static void sort (double[] array, int start, int end)

Added in API level 1

Sorts the specified range in the array in ascending numerical order. The values are sorted according to the order imposed by Double.compareTo().

Parameters
array double: the double array to be sorted.
start int: the start index to sort.
end int: the last + 1 index to sort.
Throws
IllegalArgumentException if start > end.
ArrayIndexOutOfBoundsException if start < 0 or end > array.length.

See also:

public static void sort (float[] array)

Added in API level 1

Sorts the specified array in ascending numerical order.

Parameters
array float: the float array to be sorted.

public static void sort (T[] array, int start, int end, Comparator<? super T> comparator)

Added in API level 1

Sorts the specified range in the array using the specified Comparator. All elements must be comparable to each other without a ClassCastException being thrown.

Parameters
array T
start int: the start index to sort.
end int: the last + 1 index to sort.
comparator Comparator: the Comparator.
Throws
ClassCastException if elements in the array cannot be compared to each other using the given Comparator.
IllegalArgumentException if start > end.
ArrayIndexOutOfBoundsException if start < 0 or end > array.length.

public static void sort (byte[] array, int start, int end)

Added in API level 1

Sorts the specified range in the array in ascending numerical order.

Parameters
array byte: the byte array to be sorted.
start int: the start index to sort.
end int: the last + 1 index to sort.
Throws
IllegalArgumentException if start > end.
ArrayIndexOutOfBoundsException if start < 0 or end > array.length.

public static void sort (long[] array)

Added in API level 1

Sorts the specified array in ascending numerical order.

Parameters
array long: the long array to be sorted.

public static void sort (float[] array, int start, int end)

Added in API level 1

Sorts the specified range in the array in ascending numerical order. The values are sorted according to the order imposed by Float.compareTo().

Parameters
array float: the float array to be sorted.
start int: the start index to sort.
end int: the last + 1 index to sort.
Throws
IllegalArgumentException if start > end.
ArrayIndexOutOfBoundsException if start < 0 or end > array.length.

See also:

public static void sort (short[] array, int start, int end)

Added in API level 1

Sorts the specified range in the array in ascending numerical order.

Parameters
array short: the short array to be sorted.
start int: the start index to sort.
end int: the last + 1 index to sort.
Throws
IllegalArgumentException if start > end.
ArrayIndexOutOfBoundsException if start < 0 or end > array.length.

public static void sort (byte[] array)

Added in API level 1

Sorts the specified array in ascending numerical order.

Parameters
array byte: the byte array to be sorted.

public static void sort (short[] array)

Added in API level 1

Sorts the specified array in ascending numerical order.

Parameters
array short: the short array to be sorted.

public static void sort (Object[] array, int start, int end)

Added in API level 1

Sorts the specified range in the array in ascending natural order.

Parameters
array Object
start int: the start index to sort.
end int: the last + 1 index to sort.
Throws
ClassCastException if any element does not implement Comparable, or if compareTo throws for any pair of elements.
IllegalArgumentException if start > end.
ArrayIndexOutOfBoundsException if start < 0 or end > array.length.

public static void sort (double[] array)

Added in API level 1

Sorts the specified array in ascending numerical order.

Parameters
array double: the double array to be sorted.

public static String toString (long[] array)

Added in API level 1

Creates a String representation of the long[] passed. The result is surrounded by brackets ("[]"), each element is converted to a String via the valueOf(long) and separated by ", ". If the array is null, then "null" is returned.

Parameters
array long: the long array to convert.
Returns
String the String representation of array.

public static String toString (int[] array)

Added in API level 1

Creates a String representation of the int[] passed. The result is surrounded by brackets ("[]"), each element is converted to a String via the valueOf(int) and separated by ", ". If the array is null, then "null" is returned.

Parameters
array int: the int array to convert.
Returns
String the String representation of array.

public static String toString (char[] array)

Added in API level 1

Creates a String representation of the char[] passed. The result is surrounded by brackets ("[]"), each element is converted to a String via the valueOf(char) and separated by ", ". If the array is null, then "null" is returned.

Parameters
array char: the char array to convert.
Returns
String the String representation of array.

public static String toString (boolean[] array)

Added in API level 1

Creates a String representation of the boolean[] passed. The result is surrounded by brackets ("[]"), each element is converted to a String via the valueOf(boolean) and separated by ", ". If the array is null, then "null" is returned.

Parameters
array boolean: the boolean array to convert.
Returns
String the String representation of array.

public static String toString (byte[] array)

Added in API level 1

Creates a String representation of the byte[] passed. The result is surrounded by brackets ("[]"), each element is converted to a String via the valueOf(int) and separated by ", ". If the array is null, then "null" is returned.

Parameters
array byte: the byte array to convert.
Returns
String the String representation of array.

public static String toString (float[] array)

Added in API level 1

Creates a String representation of the float[] passed. The result is surrounded by brackets ("[]"), each element is converted to a String via the valueOf(float) and separated by ", ". If the array is null, then "null" is returned.

Parameters
array float: the float array to convert.
Returns
String the String representation of array.

public static String toString (short[] array)

Added in API level 1

Creates a String representation of the short[] passed. The result is surrounded by brackets ("[]"), each element is converted to a String via the valueOf(int) and separated by ", ". If the array is null, then "null" is returned.

Parameters
array short: the short array to convert.
Returns
String the String representation of array.

public static String toString (Object[] array)

Added in API level 1

Creates a String representation of the Object[] passed. The result is surrounded by brackets ("[]"), each element is converted to a String via the valueOf(Object) and separated by ", ". If the array is null, then "null" is returned.

Parameters
array Object: the Object array to convert.
Returns
String the String representation of array.

public static String toString (double[] array)

Added in API level 1

Creates a String representation of the double[] passed. The result is surrounded by brackets ("[]"), each element is converted to a String via the valueOf(double) and separated by ", ". If the array is null, then "null" is returned.

Parameters
array double: the double array to convert.
Returns
String the String representation of array.