Arrays (Java Platform SE 7 ) (original) (raw)

Modifier and Type

Method and Description

static <T> [List](../../java/util/List.html "interface in java.util")<T>

**[asList](../../java/util/Arrays.html#asList%28T...%29)**(T... a)

Returns a fixed-size list backed by the specified array.

static int

**[binarySearch](../../java/util/Arrays.html#binarySearch%28byte[],%20byte%29)**(byte[] a, byte key)

Searches the specified array of bytes for the specified value using the binary search algorithm.

static int

**[binarySearch](../../java/util/Arrays.html#binarySearch%28byte[],%20int,%20int,%20byte%29)**(byte[] a, int fromIndex, int toIndex, byte key)

Searches a range of the specified array of bytes for the specified value using the binary search algorithm.

static int

**[binarySearch](../../java/util/Arrays.html#binarySearch%28char[],%20char%29)**(char[] a, char key)

Searches the specified array of chars for the specified value using the binary search algorithm.

static int

**[binarySearch](../../java/util/Arrays.html#binarySearch%28char[],%20int,%20int,%20char%29)**(char[] a, int fromIndex, int toIndex, char key)

Searches a range of the specified array of chars for the specified value using the binary search algorithm.

static int

**[binarySearch](../../java/util/Arrays.html#binarySearch%28double[],%20double%29)**(double[] a, double key)

Searches the specified array of doubles for the specified value using the binary search algorithm.

static int

**[binarySearch](../../java/util/Arrays.html#binarySearch%28double[],%20int,%20int,%20double%29)**(double[] a, int fromIndex, int toIndex, double key)

Searches a range of the specified array of doubles for the specified value using the binary search algorithm.

static int

**[binarySearch](../../java/util/Arrays.html#binarySearch%28float[],%20float%29)**(float[] a, float key)

Searches the specified array of floats for the specified value using the binary search algorithm.

static int

**[binarySearch](../../java/util/Arrays.html#binarySearch%28float[],%20int,%20int,%20float%29)**(float[] a, int fromIndex, int toIndex, float key)

Searches a range of the specified array of floats for the specified value using the binary search algorithm.

static int

**[binarySearch](../../java/util/Arrays.html#binarySearch%28int[],%20int%29)**(int[] a, int key)

Searches the specified array of ints for the specified value using the binary search algorithm.

static int

**[binarySearch](../../java/util/Arrays.html#binarySearch%28int[],%20int,%20int,%20int%29)**(int[] a, int fromIndex, int toIndex, int key)

Searches a range of the specified array of ints for the specified value using the binary search algorithm.

static int

**[binarySearch](../../java/util/Arrays.html#binarySearch%28long[],%20int,%20int,%20long%29)**(long[] a, int fromIndex, int toIndex, long key)

Searches a range of the specified array of longs for the specified value using the binary search algorithm.

static int

**[binarySearch](../../java/util/Arrays.html#binarySearch%28long[],%20long%29)**(long[] a, long key)

Searches the specified array of longs for the specified value using the binary search algorithm.

static int

**[binarySearch](../../java/util/Arrays.html#binarySearch%28java.lang.Object[],%20int,%20int,%20java.lang.Object%29)**([Object](../../java/lang/Object.html "class in java.lang")[] a, int fromIndex, int toIndex,[Object](../../java/lang/Object.html "class in java.lang") key)

Searches a range of the specified array for the specified object using the binary search algorithm.

static int

**[binarySearch](../../java/util/Arrays.html#binarySearch%28java.lang.Object[],%20java.lang.Object%29)**([Object](../../java/lang/Object.html "class in java.lang")[] a,[Object](../../java/lang/Object.html "class in java.lang") key)

Searches the specified array for the specified object using the binary search algorithm.

static int

**[binarySearch](../../java/util/Arrays.html#binarySearch%28short[],%20int,%20int,%20short%29)**(short[] a, int fromIndex, int toIndex, short key)

Searches a range of the specified array of shorts for the specified value using the binary search algorithm.

static int

**[binarySearch](../../java/util/Arrays.html#binarySearch%28short[],%20short%29)**(short[] a, short key)

Searches the specified array of shorts for the specified value using the binary search algorithm.

static <T> int

**[binarySearch](../../java/util/Arrays.html#binarySearch%28T[],%20int,%20int,%20T,%20java.util.Comparator%29)**(T[] a, int fromIndex, int toIndex, T key,[Comparator](../../java/util/Comparator.html "interface in java.util")<? super T> c)

Searches a range of the specified array for the specified object using the binary search algorithm.

static <T> int

**[binarySearch](../../java/util/Arrays.html#binarySearch%28T[],%20T,%20java.util.Comparator%29)**(T[] a, T key,[Comparator](../../java/util/Comparator.html "interface in java.util")<? super T> c)

Searches the specified array for the specified object using the binary search algorithm.

static boolean[]

**[copyOf](../../java/util/Arrays.html#copyOf%28boolean[],%20int%29)**(boolean[] original, int newLength)

Copies the specified array, truncating or padding with

false

(if necessary) so the copy has the specified length.

static byte[]

**[copyOf](../../java/util/Arrays.html#copyOf%28byte[],%20int%29)**(byte[] original, int newLength)

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.

static char[]

**[copyOf](../../java/util/Arrays.html#copyOf%28char[],%20int%29)**(char[] original, int newLength)

Copies the specified array, truncating or padding with null characters (if necessary) so the copy has the specified length.

static double[]

**[copyOf](../../java/util/Arrays.html#copyOf%28double[],%20int%29)**(double[] original, int newLength)

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.

static float[]

**[copyOf](../../java/util/Arrays.html#copyOf%28float[],%20int%29)**(float[] original, int newLength)

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.

static int[]

**[copyOf](../../java/util/Arrays.html#copyOf%28int[],%20int%29)**(int[] original, int newLength)

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.

static long[]

**[copyOf](../../java/util/Arrays.html#copyOf%28long[],%20int%29)**(long[] original, int newLength)

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.

static short[]

**[copyOf](../../java/util/Arrays.html#copyOf%28short[],%20int%29)**(short[] original, int newLength)

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.

static <T> T[]

**[copyOf](../../java/util/Arrays.html#copyOf%28T[],%20int%29)**(T[] original, int newLength)

Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length.

static <T,U> T[]

**[copyOf](../../java/util/Arrays.html#copyOf%28U[],%20int,%20java.lang.Class%29)**(U[] original, int newLength,[Class](../../java/lang/Class.html "class in java.lang")<? extends T[]> newType)

Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length.

static boolean[]

**[copyOfRange](../../java/util/Arrays.html#copyOfRange%28boolean[],%20int,%20int%29)**(boolean[] original, int from, int to)

Copies the specified range of the specified array into a new array.

static byte[]

**[copyOfRange](../../java/util/Arrays.html#copyOfRange%28byte[],%20int,%20int%29)**(byte[] original, int from, int to)

Copies the specified range of the specified array into a new array.

static char[]

**[copyOfRange](../../java/util/Arrays.html#copyOfRange%28char[],%20int,%20int%29)**(char[] original, int from, int to)

Copies the specified range of the specified array into a new array.

static double[]

**[copyOfRange](../../java/util/Arrays.html#copyOfRange%28double[],%20int,%20int%29)**(double[] original, int from, int to)

Copies the specified range of the specified array into a new array.

static float[]

**[copyOfRange](../../java/util/Arrays.html#copyOfRange%28float[],%20int,%20int%29)**(float[] original, int from, int to)

Copies the specified range of the specified array into a new array.

static int[]

**[copyOfRange](../../java/util/Arrays.html#copyOfRange%28int[],%20int,%20int%29)**(int[] original, int from, int to)

Copies the specified range of the specified array into a new array.

static long[]

**[copyOfRange](../../java/util/Arrays.html#copyOfRange%28long[],%20int,%20int%29)**(long[] original, int from, int to)

Copies the specified range of the specified array into a new array.

static short[]

**[copyOfRange](../../java/util/Arrays.html#copyOfRange%28short[],%20int,%20int%29)**(short[] original, int from, int to)

Copies the specified range of the specified array into a new array.

static <T> T[]

**[copyOfRange](../../java/util/Arrays.html#copyOfRange%28T[],%20int,%20int%29)**(T[] original, int from, int to)

Copies the specified range of the specified array into a new array.

static <T,U> T[]

**[copyOfRange](../../java/util/Arrays.html#copyOfRange%28U[],%20int,%20int,%20java.lang.Class%29)**(U[] original, int from, int to,[Class](../../java/lang/Class.html "class in java.lang")<? extends T[]> newType)

Copies the specified range of the specified array into a new array.

static boolean

**[deepEquals](../../java/util/Arrays.html#deepEquals%28java.lang.Object[],%20java.lang.Object[]%29)**([Object](../../java/lang/Object.html "class in java.lang")[] a1,[Object](../../java/lang/Object.html "class in java.lang")[] a2)

Returns

true

if the two specified arrays are deeply equal to one another.

static int

**[deepHashCode](../../java/util/Arrays.html#deepHashCode%28java.lang.Object[]%29)**([Object](../../java/lang/Object.html "class in java.lang")[] a)

Returns a hash code based on the "deep contents" of the specified array.

static [String](../../java/lang/String.html "class in java.lang")

**[deepToString](../../java/util/Arrays.html#deepToString%28java.lang.Object[]%29)**([Object](../../java/lang/Object.html "class in java.lang")[] a)

Returns a string representation of the "deep contents" of the specified array.

static boolean

**[equals](../../java/util/Arrays.html#equals%28boolean[],%20boolean[]%29)**(boolean[] a, boolean[] a2)

Returns

true

if the two specified arrays of booleans are_equal_ to one another.

static boolean

**[equals](../../java/util/Arrays.html#equals%28byte[],%20byte[]%29)**(byte[] a, byte[] a2)

Returns

true

if the two specified arrays of bytes are_equal_ to one another.

static boolean

**[equals](../../java/util/Arrays.html#equals%28char[],%20char[]%29)**(char[] a, char[] a2)

Returns

true

if the two specified arrays of chars are_equal_ to one another.

static boolean

**[equals](../../java/util/Arrays.html#equals%28double[],%20double[]%29)**(double[] a, double[] a2)

Returns

true

if the two specified arrays of doubles are_equal_ to one another.

static boolean

**[equals](../../java/util/Arrays.html#equals%28float[],%20float[]%29)**(float[] a, float[] a2)

Returns

true

if the two specified arrays of floats are_equal_ to one another.

static boolean

**[equals](../../java/util/Arrays.html#equals%28int[],%20int[]%29)**(int[] a, int[] a2)

Returns

true

if the two specified arrays of ints are_equal_ to one another.

static boolean

**[equals](../../java/util/Arrays.html#equals%28long[],%20long[]%29)**(long[] a, long[] a2)

Returns

true

if the two specified arrays of longs are_equal_ to one another.

static boolean

**[equals](../../java/util/Arrays.html#equals%28java.lang.Object[],%20java.lang.Object[]%29)**([Object](../../java/lang/Object.html "class in java.lang")[] a,[Object](../../java/lang/Object.html "class in java.lang")[] a2)

Returns

true

if the two specified arrays of Objects are_equal_ to one another.

static boolean

**[equals](../../java/util/Arrays.html#equals%28short[],%20short[]%29)**(short[] a, short[] a2)

Returns

true

if the two specified arrays of shorts are_equal_ to one another.

static void

**[fill](../../java/util/Arrays.html#fill%28boolean[],%20boolean%29)**(boolean[] a, boolean val)

Assigns the specified boolean value to each element of the specified array of booleans.

static void

**[fill](../../java/util/Arrays.html#fill%28boolean[],%20int,%20int,%20boolean%29)**(boolean[] a, int fromIndex, int toIndex, boolean val)

Assigns the specified boolean value to each element of the specified range of the specified array of booleans.

static void

**[fill](../../java/util/Arrays.html#fill%28byte[],%20byte%29)**(byte[] a, byte val)

Assigns the specified byte value to each element of the specified array of bytes.

static void

**[fill](../../java/util/Arrays.html#fill%28byte[],%20int,%20int,%20byte%29)**(byte[] a, int fromIndex, int toIndex, byte val)

Assigns the specified byte value to each element of the specified range of the specified array of bytes.

static void

**[fill](../../java/util/Arrays.html#fill%28char[],%20char%29)**(char[] a, char val)

Assigns the specified char value to each element of the specified array of chars.

static void

**[fill](../../java/util/Arrays.html#fill%28char[],%20int,%20int,%20char%29)**(char[] a, int fromIndex, int toIndex, char val)

Assigns the specified char value to each element of the specified range of the specified array of chars.

static void

**[fill](../../java/util/Arrays.html#fill%28double[],%20double%29)**(double[] a, double val)

Assigns the specified double value to each element of the specified array of doubles.

static void

**[fill](../../java/util/Arrays.html#fill%28double[],%20int,%20int,%20double%29)**(double[] a, int fromIndex, int toIndex, double val)

Assigns the specified double value to each element of the specified range of the specified array of doubles.

static void

**[fill](../../java/util/Arrays.html#fill%28float[],%20float%29)**(float[] a, float val)

Assigns the specified float value to each element of the specified array of floats.

static void

**[fill](../../java/util/Arrays.html#fill%28float[],%20int,%20int,%20float%29)**(float[] a, int fromIndex, int toIndex, float val)

Assigns the specified float value to each element of the specified range of the specified array of floats.

static void

**[fill](../../java/util/Arrays.html#fill%28int[],%20int%29)**(int[] a, int val)

Assigns the specified int value to each element of the specified array of ints.

static void

**[fill](../../java/util/Arrays.html#fill%28int[],%20int,%20int,%20int%29)**(int[] a, int fromIndex, int toIndex, int val)

Assigns the specified int value to each element of the specified range of the specified array of ints.

static void

**[fill](../../java/util/Arrays.html#fill%28long[],%20int,%20int,%20long%29)**(long[] a, int fromIndex, int toIndex, long val)

Assigns the specified long value to each element of the specified range of the specified array of longs.

static void

**[fill](../../java/util/Arrays.html#fill%28long[],%20long%29)**(long[] a, long val)

Assigns the specified long value to each element of the specified array of longs.

static void

**[fill](../../java/util/Arrays.html#fill%28java.lang.Object[],%20int,%20int,%20java.lang.Object%29)**([Object](../../java/lang/Object.html "class in java.lang")[] a, int fromIndex, int toIndex,[Object](../../java/lang/Object.html "class in java.lang") val)

Assigns the specified Object reference to each element of the specified range of the specified array of Objects.

static void

**[fill](../../java/util/Arrays.html#fill%28java.lang.Object[],%20java.lang.Object%29)**([Object](../../java/lang/Object.html "class in java.lang")[] a,[Object](../../java/lang/Object.html "class in java.lang") val)

Assigns the specified Object reference to each element of the specified array of Objects.

static void

**[fill](../../java/util/Arrays.html#fill%28short[],%20int,%20int,%20short%29)**(short[] a, int fromIndex, int toIndex, short val)

Assigns the specified short value to each element of the specified range of the specified array of shorts.

static void

**[fill](../../java/util/Arrays.html#fill%28short[],%20short%29)**(short[] a, short val)

Assigns the specified short value to each element of the specified array of shorts.

static int

**[hashCode](../../java/util/Arrays.html#hashCode%28boolean[]%29)**(boolean[] a)

Returns a hash code based on the contents of the specified array.

static int

**[hashCode](../../java/util/Arrays.html#hashCode%28byte[]%29)**(byte[] a)

Returns a hash code based on the contents of the specified array.

static int

**[hashCode](../../java/util/Arrays.html#hashCode%28char[]%29)**(char[] a)

Returns a hash code based on the contents of the specified array.

static int

**[hashCode](../../java/util/Arrays.html#hashCode%28double[]%29)**(double[] a)

Returns a hash code based on the contents of the specified array.

static int

**[hashCode](../../java/util/Arrays.html#hashCode%28float[]%29)**(float[] a)

Returns a hash code based on the contents of the specified array.

static int

**[hashCode](../../java/util/Arrays.html#hashCode%28int[]%29)**(int[] a)

Returns a hash code based on the contents of the specified array.

static int

**[hashCode](../../java/util/Arrays.html#hashCode%28long[]%29)**(long[] a)

Returns a hash code based on the contents of the specified array.

static int

**[hashCode](../../java/util/Arrays.html#hashCode%28java.lang.Object[]%29)**([Object](../../java/lang/Object.html "class in java.lang")[] a)

Returns a hash code based on the contents of the specified array.

static int

**[hashCode](../../java/util/Arrays.html#hashCode%28short[]%29)**(short[] a)

Returns a hash code based on the contents of the specified array.

static void

**[sort](../../java/util/Arrays.html#sort%28byte[]%29)**(byte[] a)

Sorts the specified array into ascending numerical order.

static void

**[sort](../../java/util/Arrays.html#sort%28byte[],%20int,%20int%29)**(byte[] a, int fromIndex, int toIndex)

Sorts the specified range of the array into ascending order.

static void

**[sort](../../java/util/Arrays.html#sort%28char[]%29)**(char[] a)

Sorts the specified array into ascending numerical order.

static void

**[sort](../../java/util/Arrays.html#sort%28char[],%20int,%20int%29)**(char[] a, int fromIndex, int toIndex)

Sorts the specified range of the array into ascending order.

static void

**[sort](../../java/util/Arrays.html#sort%28double[]%29)**(double[] a)

Sorts the specified array into ascending numerical order.

static void

**[sort](../../java/util/Arrays.html#sort%28double[],%20int,%20int%29)**(double[] a, int fromIndex, int toIndex)

Sorts the specified range of the array into ascending order.

static void

**[sort](../../java/util/Arrays.html#sort%28float[]%29)**(float[] a)

Sorts the specified array into ascending numerical order.

static void

**[sort](../../java/util/Arrays.html#sort%28float[],%20int,%20int%29)**(float[] a, int fromIndex, int toIndex)

Sorts the specified range of the array into ascending order.

static void

**[sort](../../java/util/Arrays.html#sort%28int[]%29)**(int[] a)

Sorts the specified array into ascending numerical order.

static void

**[sort](../../java/util/Arrays.html#sort%28int[],%20int,%20int%29)**(int[] a, int fromIndex, int toIndex)

Sorts the specified range of the array into ascending order.

static void

**[sort](../../java/util/Arrays.html#sort%28long[]%29)**(long[] a)

Sorts the specified array into ascending numerical order.

static void

**[sort](../../java/util/Arrays.html#sort%28long[],%20int,%20int%29)**(long[] a, int fromIndex, int toIndex)

Sorts the specified range of the array into ascending order.

static void

**[sort](../../java/util/Arrays.html#sort%28java.lang.Object[]%29)**([Object](../../java/lang/Object.html "class in java.lang")[] a)

Sorts the specified array of objects into ascending order, according to the natural ordering of its elements.

static void

**[sort](../../java/util/Arrays.html#sort%28java.lang.Object[],%20int,%20int%29)**([Object](../../java/lang/Object.html "class in java.lang")[] a, int fromIndex, int toIndex)

Sorts the specified range of the specified array of objects into ascending order, according to thenatural ordering of its elements.

static void

**[sort](../../java/util/Arrays.html#sort%28short[]%29)**(short[] a)

Sorts the specified array into ascending numerical order.

static void

**[sort](../../java/util/Arrays.html#sort%28short[],%20int,%20int%29)**(short[] a, int fromIndex, int toIndex)

Sorts the specified range of the array into ascending order.

static <T> void

**[sort](../../java/util/Arrays.html#sort%28T[],%20java.util.Comparator%29)**(T[] a,[Comparator](../../java/util/Comparator.html "interface in java.util")<? super T> c)

Sorts the specified array of objects according to the order induced by the specified comparator.

static <T> void

**[sort](../../java/util/Arrays.html#sort%28T[],%20int,%20int,%20java.util.Comparator%29)**(T[] a, int fromIndex, int toIndex,[Comparator](../../java/util/Comparator.html "interface in java.util")<? super T> c)

Sorts the specified range of the specified array of objects according to the order induced by the specified comparator.

static [String](../../java/lang/String.html "class in java.lang")

**[toString](../../java/util/Arrays.html#toString%28boolean[]%29)**(boolean[] a)

Returns a string representation of the contents of the specified array.

static [String](../../java/lang/String.html "class in java.lang")

**[toString](../../java/util/Arrays.html#toString%28byte[]%29)**(byte[] a)

Returns a string representation of the contents of the specified array.

static [String](../../java/lang/String.html "class in java.lang")

**[toString](../../java/util/Arrays.html#toString%28char[]%29)**(char[] a)

Returns a string representation of the contents of the specified array.

static [String](../../java/lang/String.html "class in java.lang")

**[toString](../../java/util/Arrays.html#toString%28double[]%29)**(double[] a)

Returns a string representation of the contents of the specified array.

static [String](../../java/lang/String.html "class in java.lang")

**[toString](../../java/util/Arrays.html#toString%28float[]%29)**(float[] a)

Returns a string representation of the contents of the specified array.

static [String](../../java/lang/String.html "class in java.lang")

**[toString](../../java/util/Arrays.html#toString%28int[]%29)**(int[] a)

Returns a string representation of the contents of the specified array.

static [String](../../java/lang/String.html "class in java.lang")

**[toString](../../java/util/Arrays.html#toString%28long[]%29)**(long[] a)

Returns a string representation of the contents of the specified array.

static [String](../../java/lang/String.html "class in java.lang")

**[toString](../../java/util/Arrays.html#toString%28java.lang.Object[]%29)**([Object](../../java/lang/Object.html "class in java.lang")[] a)

Returns a string representation of the contents of the specified array.

static [String](../../java/lang/String.html "class in java.lang")

**[toString](../../java/util/Arrays.html#toString%28short[]%29)**(short[] a)

Returns a string representation of the contents of the specified array.