|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object![]()
![]()
![]()
java.util.Arrays
public class Arrays

This class contains various methods for manipulating arrays (such as sorting and searching). This class also contains a static factory that allows arrays to be viewed as lists.
The methods in this class all throw a NullPointerException if the specified array reference is null, except where noted.
The documentation for the methods contained in this class includes briefs description of the implementations. Such descriptions should be regarded as implementation notes, rather than parts of the specification. Implementors should feel free to substitute other algorithms, so long as the specification itself is adhered to. (For example, the algorithm used by sort(Object[]) does not have to be a mergesort, but it does have to be stable.)
This class is a member of the Java Collections Framework.
Comparable
,
Comparator

| Method Summary | ||
|---|---|---|
static
|
asList
Returns a fixed-size list backed by the specified array. |
|
static int |
binarySearch
Searches the specified array of bytes for the specified value using the binary search algorithm. |
|
static int |
binarySearch
Searches the specified array of chars for the specified value using the binary search algorithm. |
|
static int |
binarySearch
Searches the specified array of doubles for the specified value using the binary search algorithm. |
|
static int |
binarySearch
Searches the specified array of floats for the specified value using the binary search algorithm. |
|
static int |
binarySearch
Searches the specified array of ints for the specified value using the binary search algorithm. |
|
static int |
binarySearch
Searches the specified array of longs for the specified value using the binary search algorithm. |
|
static int |
binarySearch
Searches the specified array for the specified object using the binary search algorithm. |
|
static int |
binarySearch
Searches the specified array of shorts for the specified value using the binary search algorithm. |
|
static
|
binarySearch
Searches the specified array for the specified object using the binary search algorithm. |
|
static boolean |
deepEquals
Returns true if the two specified arrays are deeply equal to one another. |
|
static int |
deepHashCode
Returns a hash code based on the "deep contents" of the specified array. |
|
static String |
deepToString
Returns a string representation of the "deep contents" of the specified array. |
|
static boolean |
equals
Returns true if the two specified arrays of booleans are equal to one another. |
|
static boolean |
equals
Returns true if the two specified arrays of bytes are equal to one another. |
|
static boolean |
equals
Returns true if the two specified arrays of chars are equal to one another. |
|
static boolean |
equals
Returns true if the two specified arrays of doubles are equal to one another. |
|
static boolean |
equals
Returns true if the two specified arrays of floats are equal to one another. |
|
static boolean |
equals
Returns true if the two specified arrays of ints are equal to one another. |
|
static boolean |
equals
Returns true if the two specified arrays of longs are equal to one another. |
|
static boolean |
equals
Returns true if the two specified arrays of Objects are equal to one another. |
|
static boolean |
equals
Returns true if the two specified arrays of shorts are equal to one another. |
|
static void |
fill
Assigns the specified boolean value to each element of the specified array of booleans. |
|
static void |
fill
Assigns the specified boolean value to each element of the specified range of the specified array of booleans. |
|
static void |
fill
Assigns the specified byte value to each element of the specified array of bytes. |
|
static void |
fill
Assigns the specified byte value to each element of the specified range of the specified array of bytes. |
|
static void |
fill
Assigns the specified char value to each element of the specified array of chars. |
|
static void |
fill
Assigns the specified char value to each element of the specified range of the specified array of chars. |
|
static void |
fill
Assigns the specified double value to each element of the specified array of doubles. |
|
static void |
fill
Assigns the specified double value to each element of the specified range of the specified array of doubles. |
|
static void |
fill
Assigns the specified float value to each element of the specified array of floats. |
|
static void |
fill
Assigns the specified float value to each element of the specified range of the specified array of floats. |
|
static void |
fill
Assigns the specified int value to each element of the specified array of ints. |
|
static void |
fill
Assigns the specified int value to each element of the specified range of the specified array of ints. |
|
static void |
fill
Assigns the specified long value to each element of the specified range of the specified array of longs. |
|
static void |
fill
Assigns the specified long value to each element of the specified array of longs. |
|
static void |
fill
Assigns the specified Object reference to each element of the specified range of the specified array of Objects. |
|
static void |
fill
Assigns the specified Object reference to each element of the specified array of Objects. |
|
static void |
fill
Assigns the specified short value to each element of the specified range of the specified array of shorts. |
|
static void |
fill
Assigns the specified short value to each element of the specified array of shorts. |
|
static int |
hashCode
Returns a hash code based on the contents of the specified array. |
|
static int |
hashCode
Returns a hash code based on the contents of the specified array. |
|
static int |
hashCode
Returns a hash code based on the contents of the specified array. |
|
static int |
hashCode
Returns a hash code based on the contents of the specified array. |
|
static int |
hashCode
Returns a hash code based on the contents of the specified array. |
|
static int |
hashCode
Returns a hash code based on the contents of the specified array. |
|
static int |
hashCode
Returns a hash code based on the contents of the specified array. |
|
static int |
hashCode
Returns a hash code based on the contents of the specified array. |
|
static int |
hashCode
Returns a hash code based on the contents of the specified array. |
|
static void |
sort
Sorts the specified array of bytes into ascending numerical order. |
|
static void |
sort
Sorts the specified range of the specified array of bytes into ascending numerical order. |
|
static void |
sort
Sorts the specified array of chars into ascending numerical order. |
|
static void |
sort
Sorts the specified range of the specified array of chars into ascending numerical order. |
|
static void |
sort
Sorts the specified array of doubles into ascending numerical order. |
|
static void |
sort
Sorts the specified range of the specified array of doubles into ascending numerical order. |
|
static void |
sort
Sorts the specified array of floats into ascending numerical order. |
|
static void |
sort
Sorts the specified range of the specified array of floats into ascending numerical order. |
|
static void |
sort
Sorts the specified array of ints into ascending numerical order. |
|
static void |
sort
Sorts the specified range of the specified array of ints into ascending numerical order. |
|
static void |
sort
Sorts the specified array of longs into ascending numerical order. |
|
static void |
sort
Sorts the specified range of the specified array of longs into ascending numerical order. |
|
static void |
sort
Sorts the specified array of objects into ascending order, according to the natural ordering of its elements. |
|
static void |
sort
Sorts the specified range of the specified array of objects into ascending order, according to the natural ordering of its elements. |
|
static void |
sort
Sorts the specified array of shorts into ascending numerical order. |
|
static void |
sort
Sorts the specified range of the specified array of shorts into ascending numerical order. |
|
static
|
sort
Sorts the specified array of objects according to the order induced by the specified comparator. |
|
static
|
sort
Sorts the specified range of the specified array of objects according to the order induced by the specified comparator. |
|
static String |
toString
Returns a string representation of the contents of the specified array. |
|
static String |
toString
Returns a string representation of the contents of the specified array. |
|
static String |
toString
Returns a string representation of the contents of the specified array. |
|
static String |
toString
Returns a string representation of the contents of the specified array. |
|
static String |
toString
Returns a string representation of the contents of the specified array. |
|
static String |
toString
Returns a string representation of the contents of the specified array. |
|
static String |
toString
Returns a string representation of the contents of the specified array. |
|
static String |
toString
Returns a string representation of the contents of the specified array. |
|
static String |
toString
Returns a string representation of the contents of the specified array. |
|
Methods inherited from class java.lang.Object ![]() |
|---|
clone |
| Method Detail |
|---|

public static void sort(long[] a)
a - the array to be sorted.

public static void sort(long[] a,
int fromIndex,
int toIndex)
The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance.
a - the array to be sorted.fromIndex - the index of the first element (inclusive) to be
sorted.toIndex - the index of the last element (exclusive) to be sorted.
IllegalArgumentException

- if fromIndex > toIndex
ArrayIndexOutOfBoundsException

- if fromIndex < 0 or
toIndex > a.length

public static void sort(int[] a)
a - the array to be sorted.

public static void sort(int[] a,
int fromIndex,
int toIndex)
The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance.
a - the array to be sorted.fromIndex - the index of the first element (inclusive) to be
sorted.toIndex - the index of the last element (exclusive) to be sorted.
IllegalArgumentException

- if fromIndex > toIndex
ArrayIndexOutOfBoundsException

- if fromIndex < 0 or
toIndex > a.length

public static void sort(short[] a)
a - the array to be sorted.

public static void sort(short[] a,
int fromIndex,
int toIndex)
The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance.
a - the array to be sorted.fromIndex - the index of the first element (inclusive) to be
sorted.toIndex - the index of the last element (exclusive) to be sorted.
IllegalArgumentException

- if fromIndex > toIndex
ArrayIndexOutOfBoundsException

- if fromIndex < 0 or
toIndex > a.length

public static void sort(char[] a)
a - the array to be sorted.

public static void sort(char[] a,
int fromIndex,
int toIndex)
The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance.
a - the array to be sorted.fromIndex - the index of the first element (inclusive) to be
sorted.toIndex - the index of the last element (exclusive) to be sorted.
IllegalArgumentException

- if fromIndex > toIndex
ArrayIndexOutOfBoundsException

- if fromIndex < 0 or
toIndex > a.length

public static void sort(byte[] a)
a - the array to be sorted.

public static void sort(byte[] a,
int fromIndex,
int toIndex)
The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance.
a - the array to be sorted.fromIndex - the index of the first element (inclusive) to be
sorted.toIndex - the index of the last element (exclusive) to be sorted.
IllegalArgumentException