public class Arrays extends Object
Arrays contains static methods which operate on arrays.| Modifier and Type | Method and Description |
|---|---|
static <T> List<T> |
asList(T... array)
Returns a
List of the objects in the specified array. |
static int |
binarySearch(byte[] array,
byte value)
Performs a binary search for
value in the ascending sorted array array. |
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(char[] array,
char value)
Performs a binary search for
value in the ascending sorted array array. |
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(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(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(int[] array,
int 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 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(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(Object[] array,
Object 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 int |
binarySearch(short[] array,
short value)
Performs a binary search for
value in the ascending sorted array 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 <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 void |
checkOffsetAndCount(int arrayLength,
int offset,
int count)
Checks that the range described by
offset and count doesn't exceed
arrayLength. |
static void |
checkStartAndEnd(int len,
int start,
int end)
Checks that the range described by
start and end doesn't exceed
len. |
static boolean[] |
copyOf(boolean[] 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 char[] |
copyOf(char[] 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 float[] |
copyOf(float[] 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 long[] |
copyOf(long[] original,
int newLength)
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 <T> T[] |
copyOf(T[] original,
int newLength)
Copies
newLength elements from original into a new array. |
static <T,U> T[] |
copyOf(U[] original,
int newLength,
Class<? extends T[]> newType)
Copies
newLength elements from original into a new array. |
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 byte[] |
copyOfRange(byte[] 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 double[] |
copyOfRange(double[] 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 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 short[] |
copyOfRange(short[] 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 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(boolean[] array1,
boolean[] array2)
Compares the two arrays.
|
static boolean |
equals(byte[] array1,
byte[] array2)
Compares the two arrays.
|
static boolean |
equals(char[] array1,
char[] array2)
Compares the two arrays.
|
static boolean |
equals(double[] array1,
double[] array2)
Compares the two arrays.
|
static boolean |
equals(float[] array1,
float[] array2)
Compares the two arrays.
|
static boolean |
equals(int[] array1,
int[] array2)
Compares the two arrays.
|
static boolean |
equals(long[] array1,
long[] array2)
Compares the two arrays.
|
static boolean |
equals(Object[] array1,
Object[] array2)
Compares the two arrays.
|
static boolean |
equals(short[] array1,
short[] array2)
Compares the two arrays.
|
static void |
fill(boolean[] array,
boolean value)
Fills the specified array with the specified element.
|
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(byte[] array,
byte value)
Fills the specified 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(char[] array,
char 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(double[] array,
double value)
Fills the specified 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(float[] array,
float 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(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(long[] array,
int start,
int end,
long 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(Object[] array,
int start,
int end,
Object value)
Fills the specified range in the array with the specified element.
|
static void |
fill(Object[] array,
Object 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(short[] array,
short 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(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(double[] 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(int[] 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 int |
hashCode(Object[] 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 void |
parallelSetAll(double[] array,
IntToDoubleFunction generator)
Set all elements of the specified array, in parallel, using the
provided generator function to compute each element.
|
static void |
parallelSetAll(int[] array,
IntUnaryOperator generator)
Set all elements of the specified array, in parallel, using the
provided generator function to compute each element.
|
static void |
parallelSetAll(long[] array,
IntToLongFunction generator)
Set all elements of the specified array, in parallel, using the
provided generator function to compute each element.
|
static <T> void |
parallelSetAll(T[] array,
IntFunction<? extends T> generator)
Set all elements of the specified array, in parallel, using the
provided generator function to compute each element.
|
static void |
setAll(double[] array,
IntToDoubleFunction generator)
Set all elements of the specified array, using the provided
generator function to compute each element.
|
static void |
setAll(int[] array,
IntUnaryOperator generator)
Set all elements of the specified array, using the provided
generator function to compute each element.
|
static void |
setAll(long[] array,
IntToLongFunction generator)
Set all elements of the specified array, using the provided
generator function to compute each element.
|
static <T> void |
setAll(T[] array,
IntFunction<? extends T> generator)
Set all elements of the specified array, using the provided
generator function to compute each element.
|
static void |
sort(byte[] array)
Sorts the specified array in ascending numerical order.
|
static void |
sort(byte[] 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(char[] array,
int start,
int end)
Sorts the specified range in the array in ascending numerical order.
|
static void |
sort(double[] array)
Sorts the specified 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 void |
sort(float[] array,
int start,
int end)
Sorts the specified range in the array in ascending numerical order.
|
static void |
sort(int[] 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 void |
sort(long[] array)
Sorts the specified array in ascending numerical order.
|
static void |
sort(long[] array,
int start,
int end)
Sorts the specified range in the array in ascending numerical order.
|
static void |
sort(Object[] array)
Sorts the specified array in ascending natural order.
|
static void |
sort(Object[] array,
int start,
int end)
Sorts the specified range in the array in ascending natural order.
|
static void |
sort(short[] array)
Sorts the specified 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 <T> void |
sort(T[] array,
Comparator<? super T> comparator)
Sorts the specified array using the specified
Comparator. |
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 Spliterator.OfDouble |
spliterator(double[] array)
Returns a
Spliterator.OfDouble covering all of the specified
array. |
static Spliterator.OfDouble |
spliterator(double[] array,
int startInclusive,
int endExclusive)
Returns a
Spliterator.OfDouble covering the specified range of
the specified array. |
static Spliterator.OfInt |
spliterator(int[] array)
Returns a
Spliterator.OfInt covering all of the specified array. |
static Spliterator.OfInt |
spliterator(int[] array,
int startInclusive,
int endExclusive)
Returns a
Spliterator.OfInt covering the specified range of the
specified array. |
static Spliterator.OfLong |
spliterator(long[] array)
Returns a
Spliterator.OfLong covering all of the specified array. |
static Spliterator.OfLong |
spliterator(long[] array,
int startInclusive,
int endExclusive)
Returns a
Spliterator.OfLong covering the specified range of the
specified array. |
static <T> Spliterator<T> |
spliterator(T[] array)
Returns a
Spliterator covering all of the specified array. |
static <T> Spliterator<T> |
spliterator(T[] array,
int startInclusive,
int endExclusive)
Returns a
Spliterator covering the specified range of the
specified array. |
static DoubleStream |
stream(double[] array)
Returns a sequential
DoubleStream with the specified array as its
source. |
static DoubleStream |
stream(double[] array,
int startInclusive,
int endExclusive)
Returns a sequential
DoubleStream with the specified range of the
specified array as its source. |
static IntStream |
stream(int[] array)
Returns a sequential
IntStream with the specified array as its
source. |
static IntStream |
stream(int[] array,
int startInclusive,
int endExclusive)
Returns a sequential
IntStream with the specified range of the
specified array as its source. |
static LongStream |
stream(long[] array)
Returns a sequential
LongStream with the specified array as its
source. |
static LongStream |
stream(long[] array,
int startInclusive,
int endExclusive)
Returns a sequential
LongStream with the specified range of the
specified array as its source. |
static <T> Stream<T> |
stream(T[] array)
Returns a sequential
Stream with the specified array as its
source. |
static <T> Stream<T> |
stream(T[] array,
int startInclusive,
int endExclusive)
Returns a sequential
Stream with the specified range of the
specified array as its source. |
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(char[] array)
Creates a
String representation of the char[] passed. |
static String |
toString(double[] array)
Creates a
String representation of the double[] passed. |
static String |
toString(float[] array)
Creates a
String representation of the float[] passed. |
static String |
toString(int[] array)
Creates a
String representation of the int[] passed. |
static String |
toString(long[] array)
Creates a
String representation of the long[] passed. |
static String |
toString(Object[] array)
Creates a
String representation of the Object[] passed. |
static String |
toString(short[] array)
Creates a
String representation of the short[] passed. |
@SafeVarargs public static <T> List<T> asList(T... array)
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.array - the array.List of the elements of the specified array.public static int binarySearch(byte[] array,
byte value)
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.array - the sorted array to search.value - the element to find.-index - 1 where the element would be inserted.public static int binarySearch(byte[] array,
int startIndex,
int endIndex,
byte value)
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.array - the sorted array to search.startIndex - the inclusive start index.endIndex - the exclusive start index.value - the element to find.-index - 1 where the element would be inserted.IllegalArgumentException - if startIndex > endIndexArrayIndexOutOfBoundsException - if startIndex < 0 || endIndex > array.lengthpublic static int binarySearch(char[] array,
char value)
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.array - the sorted array to search.value - the element to find.-index - 1 where the element would be inserted.public static int binarySearch(char[] array,
int startIndex,
int endIndex,
char value)
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.array - the sorted array to search.startIndex - the inclusive start index.endIndex - the exclusive start index.value - the element to find.-index - 1 where the element would be inserted.IllegalArgumentException - if startIndex > endIndexArrayIndexOutOfBoundsException - if startIndex < 0 || endIndex > array.lengthpublic static int binarySearch(double[] array,
double value)
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.array - the sorted array to search.value - the element to find.-index - 1 where the element would be inserted.public static int binarySearch(double[] array,
int startIndex,
int endIndex,
double value)
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.array - the sorted array to search.startIndex - the inclusive start index.endIndex - the exclusive start index.value - the element to find.-index - 1 where the element would be inserted.IllegalArgumentException - if startIndex > endIndexArrayIndexOutOfBoundsException - if startIndex < 0 || endIndex > array.lengthpublic static int binarySearch(float[] array,
float value)
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.array - the sorted array to search.value - the element to find.-index - 1 where the element would be inserted.public static int binarySearch(float[] array,
int startIndex,
int endIndex,
float value)
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.array - the sorted array to search.startIndex - the inclusive start index.endIndex - the exclusive start index.value - the element to find.-index - 1 where the element would be inserted.IllegalArgumentException - if startIndex > endIndexArrayIndexOutOfBoundsException - if startIndex < 0 || endIndex > array.lengthpublic static int binarySearch(int[] array,
int value)
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.array - the sorted array to search.value - the element to find.-index - 1 where the element would be inserted.public static int binarySearch(int[] array,
int startIndex,
int endIndex,
int value)
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.array - the sorted array to search.startIndex - the inclusive start index.endIndex - the exclusive start index.value - the element to find.-index - 1 where the element would be inserted.IllegalArgumentException - if startIndex > endIndexArrayIndexOutOfBoundsException - if startIndex < 0 || endIndex > array.lengthpublic static int binarySearch(long[] array,
long value)
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.array - the sorted array to search.value - the element to find.-index - 1 where the element would be inserted.public static int binarySearch(long[] array,
int startIndex,
int endIndex,
long value)
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.array - the sorted array to search.startIndex - the inclusive start index.endIndex - the exclusive start index.value - the element to find.-index - 1 where the element would be inserted.IllegalArgumentException - if startIndex > endIndexArrayIndexOutOfBoundsException - if startIndex < 0 || endIndex > array.lengthpublic static int binarySearch(Object[] array, Object value)
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.array - the sorted array to search.value - the element to find.-index - 1 where the element would be inserted.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(Object[] array, int startIndex, int endIndex, Object value)
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.array - the sorted array to search.startIndex - the inclusive start index.endIndex - the exclusive start index.value - the element to find.-index - 1 where the element would be inserted.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 > endIndexArrayIndexOutOfBoundsException - if startIndex < 0 || endIndex > array.lengthpublic static <T> int binarySearch(T[] array,
T value,
Comparator<? super T> comparator)
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.array - the sorted array to search.value - the element to find.comparator - the Comparator used to compare the elements.-index - 1 where the element would be inserted.ClassCastException - if an element in the array or the search element does not
implement Comparable, or cannot be compared to each other.public static <T> int binarySearch(T[] array,
int startIndex,
int endIndex,
T value,
Comparator<? super T> comparator)
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.array - the sorted array to search.startIndex - the inclusive start index.endIndex - the exclusive start index.value - the element to find.comparator - the Comparator used to compare the elements.-index - 1 where the element would be inserted.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 > endIndexArrayIndexOutOfBoundsException - if startIndex < 0 || endIndex > array.lengthpublic static int binarySearch(short[] array,
short value)
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.array - the sorted array to search.value - the element to find.-index - 1 where the element would be inserted.public static int binarySearch(short[] array,
int startIndex,
int endIndex,
short value)
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.array - the sorted array to search.startIndex - the inclusive start index.endIndex - the exclusive start index.value - the element to find.-index - 1 where the element would be inserted.IllegalArgumentException - if startIndex > endIndexArrayIndexOutOfBoundsException - if startIndex < 0 || endIndex > array.lengthpublic static void fill(byte[] array,
byte value)
array - the byte array to fill.value - the byte element.public static void fill(byte[] array,
int start,
int end,
byte value)
array - the byte array to fill.start - the first index to fill.end - the last + 1 index to fill.value - the byte element.IllegalArgumentException - if start > end.ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.public static void fill(short[] array,
short value)
array - the short array to fill.value - the short element.public static void fill(short[] array,
int start,
int end,
short value)
array - the short array to fill.start - the first index to fill.end - the last + 1 index to fill.value - the short element.IllegalArgumentException - if start > end.ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.public static void fill(char[] array,
char value)
array - the char array to fill.value - the char element.public static void fill(char[] array,
int start,
int end,
char value)
array - the char array to fill.start - the first index to fill.end - the last + 1 index to fill.value - the char element.IllegalArgumentException - if start > end.ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.public static void fill(int[] array,
int value)
array - the int array to fill.value - the int element.public static void fill(int[] array,
int start,
int end,
int value)
array - the int array to fill.start - the first index to fill.end - the last + 1 index to fill.value - the int element.IllegalArgumentException - if start > end.ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.public static void fill(long[] array,
long value)
array - the long array to fill.value - the long element.public static void fill(long[] array,
int start,
int end,
long value)
array - the long array to fill.start - the first index to fill.end - the last + 1 index to fill.value - the long element.IllegalArgumentException - if start > end.ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.public static void fill(float[] array,
float value)
array - the float array to fill.value - the float element.public static void fill(float[] array,
int start,
int end,
float value)
array - the float array to fill.start - the first index to fill.end - the last + 1 index to fill.value - the float element.IllegalArgumentException - if start > end.ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.public static void fill(double[] array,
double value)
array - the double array to fill.value - the double element.public static void fill(double[] array,
int start,
int end,
double value)
array - the double array to fill.start - the first index to fill.end - the last + 1 index to fill.value - the double element.IllegalArgumentException - if start > end.ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.public static void fill(boolean[] array,
boolean value)
array - the boolean array to fill.value - the boolean element.public static void fill(boolean[] array,
int start,
int end,
boolean value)
array - the boolean array to fill.start - the first index to fill.end - the last + 1 index to fill.value - the boolean element.IllegalArgumentException - if start > end.ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.public static void fill(Object[] array, Object value)
array - the Object array to fill.value - the Object element.public static void fill(Object[] array, int start, int end, Object value)
array - the Object array to fill.start - the first index to fill.end - the last + 1 index to fill.value - the Object element.IllegalArgumentException - if start > end.ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.public static int hashCode(boolean[] array)
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
List.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.
array - the array whose hash code to compute.array.public static int hashCode(int[] array)
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
List.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.
array - the array whose hash code to compute.array.public static int hashCode(short[] array)
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
List.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.
array - the array whose hash code to compute.array.public static int hashCode(char[] array)
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
List.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.
array - the array whose hash code to compute.array.public static int hashCode(byte[] array)
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
List.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.
array - the array whose hash code to compute.array.public static int hashCode(long[] array)
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
List.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.
array - the array whose hash code to compute.array.public static int hashCode(float[] array)
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
List.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.
array - the array whose hash code to compute.array.public static int hashCode(double[] array)
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
List.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.
array - the array whose hash code to compute.array.public static int hashCode(Object[] array)
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.
array - the array whose hash code to compute.array.public static int deepHashCode(Object[] array)
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 List.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.
array - the array whose hash code to compute.array.public static boolean equals(byte[] array1,
byte[] array2)
array1 - the first byte array.array2 - the second byte array.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(short[] array1,
short[] array2)
array1 - the first short array.array2 - the second short array.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(char[] array1,
char[] array2)
array1 - the first char array.array2 - the second char array.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(int[] array1,
int[] array2)
array1 - the first int array.array2 - the second int array.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)
array1 - the first long array.array2 - the second long array.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)
Float.equals().array1 - the first float array.array2 - the second float array.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.Float.equals(Object)public static boolean equals(double[] array1,
double[] array2)
Double.equals().array1 - the first double array.array2 - the second double array.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.Double.equals(Object)public static boolean equals(boolean[] array1,
boolean[] array2)
array1 - the first boolean array.array2 - the second boolean array.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)
array1 - the first Object array.array2 - the second Object array.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 deepEquals(Object[] array1, Object[] array2)
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.
array1 - the first Object array.array2 - the second Object array.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 void sort(byte[] array)
array - the byte array to be sorted.public static void sort(byte[] array,
int start,
int end)
array - the byte array to be sorted.start - the start index to sort.end - the last + 1 index to sort.IllegalArgumentException - if start > end.ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.public static void checkOffsetAndCount(int arrayLength,
int offset,
int count)
offset and count doesn't exceed
arrayLength.public static void checkStartAndEnd(int len,
int start,
int end)
start and end doesn't exceed
len.public static void sort(char[] array)
array - the char array to be sorted.public static void sort(char[] array,
int start,
int end)
array - the char array to be sorted.start - the start index to sort.end - the last + 1 index to sort.IllegalArgumentException - if start > end.ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.public static void sort(double[] array)
array - the double array to be sorted.sort(double[], int, int)public static void sort(double[] array,
int start,
int end)
Double.compareTo().array - the double array to be sorted.start - the start index to sort.end - the last + 1 index to sort.IllegalArgumentException - if start > end.ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.Double.compareTo(Double)public static void sort(float[] array)
array - the float array to be sorted.sort(float[], int, int)public static void sort(float[] array,
int start,
int end)
Float.compareTo().array - the float array to be sorted.start - the start index to sort.end - the last + 1 index to sort.IllegalArgumentException - if start > end.ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.Float.compareTo(Float)public static void sort(int[] array)
array - the int array to be sorted.public static void sort(int[] array,
int start,
int end)
array - the int array to be sorted.start - the start index to sort.end - the last + 1 index to sort.IllegalArgumentException - if start > end.ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.public static void sort(long[] array)
array - the long array to be sorted.public static void sort(long[] array,
int start,
int end)
array - the long array to be sorted.start - the start index to sort.end - the last + 1 index to sort.IllegalArgumentException - if start > end.ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.public static void sort(short[] array)
array - the short array to be sorted.public static void sort(short[] array,
int start,
int end)
array - the short array to be sorted.start - the start index to sort.end - the last + 1 index to sort.IllegalArgumentException - if start > end.ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.public static void sort(Object[] array)
ClassCastException - if any element does not implement Comparable,
or if compareTo throws for any pair of elements.public static void sort(Object[] array, int start, int end)
start - the start index to sort.end - the last + 1 index to sort.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 <T> void sort(T[] array,
int start,
int end,
Comparator<? super T> comparator)
Comparator.
All elements must be comparable to each other without a
ClassCastException being thrown.start - the start index to sort.end - the last + 1 index to sort.comparator - the Comparator.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 <T> void sort(T[] array,
Comparator<? super T> comparator)
Comparator. All elements
must be comparable to each other without a ClassCastException being thrown.ClassCastException - if elements in the array cannot be compared to each other
using the Comparator.public static String toString(boolean[] array)
String representation of the boolean[] passed.
The result is surrounded by brackets ("[]"), each
element is converted to a String via the
String.valueOf(boolean) and separated by ", ".
If the array is null, then "null" is returned.array - the boolean array to convert.String representation of array.public static String toString(byte[] array)
String representation of the byte[] passed. The
result is surrounded by brackets ("[]"), each element
is converted to a String via the String.valueOf(int) and
separated by ", ". If the array is null, then
"null" is returned.array - the byte array to convert.String representation of array.public static String toString(char[] array)
String representation of the char[] passed. The
result is surrounded by brackets ("[]"), each element
is converted to a String via the String.valueOf(char) and
separated by ", ". If the array is null, then
"null" is returned.array - the char array to convert.String representation of array.public static String toString(double[] array)
String representation of the double[] passed.
The result is surrounded by brackets ("[]"), each
element is converted to a String via the
String.valueOf(double) and separated by ", ".
If the array is null, then "null" is returned.array - the double array to convert.String representation of array.public static String toString(float[] array)
String representation of the float[] passed.
The result is surrounded by brackets ("[]"), each
element is converted to a String via the
String.valueOf(float) and separated by ", ".
If the array is null, then "null" is returned.array - the float array to convert.String representation of array.public static String toString(int[] array)
String representation of the int[] passed. The
result is surrounded by brackets ("[]"), each element
is converted to a String via the String.valueOf(int) and
separated by ", ". If the array is null, then
"null" is returned.array - the int array to convert.String representation of array.public static String toString(long[] array)
String representation of the long[] passed. The
result is surrounded by brackets ("[]"), each element
is converted to a String via the String.valueOf(long) and
separated by ", ". If the array is null, then
"null" is returned.array - the long array to convert.String representation of array.public static String toString(short[] array)
String representation of the short[] passed.
The result is surrounded by brackets ("[]"), each
element is converted to a String via the
String.valueOf(int) and separated by ", ". If
the array is null, then "null" is returned.array - the short array to convert.String representation of array.public static String toString(Object[] array)
String representation of the Object[] passed.
The result is surrounded by brackets ("[]"), each
element is converted to a String via the
String.valueOf(Object) and separated by ", ".
If the array is null, then "null" is returned.array - the Object array to convert.String representation of array.public static String deepToString(Object[] array)
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 String.valueOf(Object) method.
array - the Object array to convert.String representation of array.public static boolean[] copyOf(boolean[] original,
int newLength)
newLength elements from original into a new array.
If newLength is greater than original.length, the result is padded
with the value false.original - the original arraynewLength - the length of the new arrayNegativeArraySizeException - if newLength < 0NullPointerException - if original == nullpublic static byte[] copyOf(byte[] original,
int newLength)
newLength elements from original into a new array.
If newLength is greater than original.length, the result is padded
with the value (byte) 0.original - the original arraynewLength - the length of the new arrayNegativeArraySizeException - if newLength < 0NullPointerException - if original == nullpublic static char[] copyOf(char[] original,
int newLength)
newLength elements from original into a new array.
If newLength is greater than original.length, the result is padded
with the value '\\u0000'.original - the original arraynewLength - the length of the new arrayNegativeArraySizeException - if newLength < 0NullPointerException - if original == nullpublic static double[] copyOf(double[] original,
int newLength)
newLength elements from original into a new array.
If newLength is greater than original.length, the result is padded
with the value 0.0d.original - the original arraynewLength - the length of the new arrayNegativeArraySizeException - if newLength < 0NullPointerException - if original == nullpublic static float[] copyOf(float[] original,
int newLength)
newLength elements from original into a new array.
If newLength is greater than original.length, the result is padded
with the value 0.0f.original - the original arraynewLength - the length of the new arrayNegativeArraySizeException - if newLength < 0NullPointerException - if original == nullpublic static int[] copyOf(int[] original,
int newLength)
newLength elements from original into a new array.
If newLength is greater than original.length, the result is padded
with the value 0.original - the original arraynewLength - the length of the new arrayNegativeArraySizeException - if newLength < 0NullPointerException - if original == nullpublic static long[] copyOf(long[] original,
int newLength)
newLength elements from original into a new array.
If newLength is greater than original.length, the result is padded
with the value 0L.original - the original arraynewLength - the length of the new arrayNegativeArraySizeException - if newLength < 0NullPointerException - if original == nullpublic static short[] copyOf(short[] original,
int newLength)
newLength elements from original into a new array.
If newLength is greater than original.length, the result is padded
with the value (short) 0.original - the original arraynewLength - the length of the new arrayNegativeArraySizeException - if newLength < 0NullPointerException - if original == nullpublic static <T> T[] copyOf(T[] original,
int newLength)
newLength elements from original into a new array.
If newLength is greater than original.length, the result is padded
with the value null.original - the original arraynewLength - the length of the new arrayNegativeArraySizeException - if newLength < 0NullPointerException - if original == nullpublic static <T,U> T[] copyOf(U[] original,
int newLength,
Class<? extends T[]> newType)
newLength elements from original into a new array.
If newLength is greater than original.length, the result is padded
with the value null.original - the original arraynewLength - the length of the new arraynewType - the class of the new arrayNegativeArraySizeException - if newLength < 0NullPointerException - if original == nullArrayStoreException - if a value in original is incompatible with Tpublic static boolean[] copyOfRange(boolean[] original,
int start,
int end)
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.original - the original arraystart - the start index, inclusiveend - the end index, exclusiveArrayIndexOutOfBoundsException - if start < 0 || start > original.lengthIllegalArgumentException - if start > endNullPointerException - if original == nullpublic static byte[] copyOfRange(byte[] original,
int start,
int end)
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.original - the original arraystart - the start index, inclusiveend - the end index, exclusiveArrayIndexOutOfBoundsException - if start < 0 || start > original.lengthIllegalArgumentException - if start > endNullPointerException - if original == nullpublic static char[] copyOfRange(char[] original,
int start,
int end)
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'.original - the original arraystart - the start index, inclusiveend - the end index, exclusiveArrayIndexOutOfBoundsException - if start < 0 || start > original.lengthIllegalArgumentException - if start > endNullPointerException - if original == nullpublic static double[] copyOfRange(double[] original,
int start,
int end)
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.original - the original arraystart - the start index, inclusiveend - the end index, exclusiveArrayIndexOutOfBoundsException - if start < 0 || start > original.lengthIllegalArgumentException - if start > endNullPointerException - if original == nullpublic static float[] copyOfRange(float[] original,
int start,
int end)
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.original - the original arraystart - the start index, inclusiveend - the end index, exclusiveArrayIndexOutOfBoundsException - if start < 0 || start > original.lengthIllegalArgumentException - if start > endNullPointerException - if original == nullpublic static int[] copyOfRange(int[] original,
int start,
int end)
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.original - the original arraystart - the start index, inclusiveend - the end index, exclusiveArrayIndexOutOfBoundsException - if start < 0 || start > original.lengthIllegalArgumentException - if start > endNullPointerException - if original == nullpublic static long[] copyOfRange(long[] original,
int start,
int end)
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.original - the original arraystart - the start index, inclusiveend - the end index, exclusiveArrayIndexOutOfBoundsException - if start < 0 || start > original.lengthIllegalArgumentException - if start > endNullPointerException - if original == nullpublic static short[] copyOfRange(short[] original,
int start,
int end)
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.original - the original arraystart - the start index, inclusiveend - the end index, exclusiveArrayIndexOutOfBoundsException - if start < 0 || start > original.lengthIllegalArgumentException - if start > endNullPointerException - if original == nullpublic static <T> T[] copyOfRange(T[] original,
int start,
int end)
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.original - the original arraystart - the start index, inclusiveend - the end index, exclusiveArrayIndexOutOfBoundsException - if start < 0 || start > original.lengthIllegalArgumentException - if start > endNullPointerException - if original == nullpublic static <T,U> T[] copyOfRange(U[] original,
int start,
int end,
Class<? extends T[]> newType)
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.original - the original arraystart - the start index, inclusiveend - the end index, exclusiveArrayIndexOutOfBoundsException - if start < 0 || start > original.lengthIllegalArgumentException - if start > endNullPointerException - if original == nullArrayStoreException - if a value in original is incompatible with Tpublic static <T> void setAll(T[] array,
IntFunction<? extends T> generator)
If the generator function throws an exception, it is relayed to the caller and the array is left in an indeterminate state.
T - type of elements of the arrayarray - array to be initializedgenerator - a function accepting an index and producing the desired
value for that positionNullPointerException - if the generator is nullpublic static <T> void parallelSetAll(T[] array,
IntFunction<? extends T> generator)
If the generator function throws an exception, an unchecked exception
is thrown from parallelSetAll and the array is left in an
indeterminate state.
T - type of elements of the arrayarray - array to be initializedgenerator - a function accepting an index and producing the desired
value for that positionNullPointerException - if the generator is nullpublic static void setAll(int[] array,
IntUnaryOperator generator)
If the generator function throws an exception, it is relayed to the caller and the array is left in an indeterminate state.
array - array to be initializedgenerator - a function accepting an index and producing the desired
value for that positionNullPointerException - if the generator is nullpublic static void parallelSetAll(int[] array,
IntUnaryOperator generator)
If the generator function throws an exception, an unchecked exception
is thrown from parallelSetAll and the array is left in an
indeterminate state.
array - array to be initializedgenerator - a function accepting an index and producing the desired
value for that positionNullPointerException - if the generator is nullpublic static void setAll(long[] array,
IntToLongFunction generator)
If the generator function throws an exception, it is relayed to the caller and the array is left in an indeterminate state.
array - array to be initializedgenerator - a function accepting an index and producing the desired
value for that positionNullPointerException - if the generator is nullpublic static void parallelSetAll(long[] array,
IntToLongFunction generator)
If the generator function throws an exception, an unchecked exception
is thrown from parallelSetAll and the array is left in an
indeterminate state.
array - array to be initializedgenerator - a function accepting an index and producing the desired
value for that positionNullPointerException - if the generator is nullpublic static void setAll(double[] array,
IntToDoubleFunction generator)
If the generator function throws an exception, it is relayed to the caller and the array is left in an indeterminate state.
array - array to be initializedgenerator - a function accepting an index and producing the desired
value for that positionNullPointerException - if the generator is nullpublic static void parallelSetAll(double[] array,
IntToDoubleFunction generator)
If the generator function throws an exception, an unchecked exception
is thrown from parallelSetAll and the array is left in an
indeterminate state.
array - array to be initializedgenerator - a function accepting an index and producing the desired
value for that positionNullPointerException - if the generator is nullpublic static <T> Spliterator<T> spliterator(T[] array)
Spliterator covering all of the specified array.
The spliterator reports Spliterator.SIZED,
Spliterator.SUBSIZED, Spliterator.ORDERED, and
Spliterator.IMMUTABLE.
T - type of elementsarray - the array, assumed to be unmodified during usepublic static <T> Spliterator<T> spliterator(T[] array, int startInclusive, int endExclusive)
Spliterator covering the specified range of the
specified array.
The spliterator reports Spliterator.SIZED,
Spliterator.SUBSIZED, Spliterator.ORDERED, and
Spliterator.IMMUTABLE.
T - type of elementsarray - the array, assumed to be unmodified during usestartInclusive - the first index to cover, inclusiveendExclusive - index immediately past the last index to coverArrayIndexOutOfBoundsException - if startInclusive is
negative, endExclusive is less than
startInclusive, or endExclusive is greater than
the array sizepublic static Spliterator.OfInt spliterator(int[] array)
Spliterator.OfInt covering all of the specified array.
The spliterator reports Spliterator.SIZED,
Spliterator.SUBSIZED, Spliterator.ORDERED, and
Spliterator.IMMUTABLE.
array - the array, assumed to be unmodified during usepublic static Spliterator.OfInt spliterator(int[] array, int startInclusive, int endExclusive)
Spliterator.OfInt covering the specified range of the
specified array.
The spliterator reports Spliterator.SIZED,
Spliterator.SUBSIZED, Spliterator.ORDERED, and
Spliterator.IMMUTABLE.
array - the array, assumed to be unmodified during usestartInclusive - the first index to cover, inclusiveendExclusive - index immediately past the last index to coverArrayIndexOutOfBoundsException - if startInclusive is
negative, endExclusive is less than
startInclusive, or endExclusive is greater than
the array sizepublic static Spliterator.OfLong spliterator(long[] array)
Spliterator.OfLong covering all of the specified array.
The spliterator reports Spliterator.SIZED,
Spliterator.SUBSIZED, Spliterator.ORDERED, and
Spliterator.IMMUTABLE.
array - the array, assumed to be unmodified during usepublic static Spliterator.OfLong spliterator(long[] array, int startInclusive, int endExclusive)
Spliterator.OfLong covering the specified range of the
specified array.
The spliterator reports Spliterator.SIZED,
Spliterator.SUBSIZED, Spliterator.ORDERED, and
Spliterator.IMMUTABLE.
array - the array, assumed to be unmodified during usestartInclusive - the first index to cover, inclusiveendExclusive - index immediately past the last index to coverArrayIndexOutOfBoundsException - if startInclusive is
negative, endExclusive is less than
startInclusive, or endExclusive is greater than
the array sizepublic static Spliterator.OfDouble spliterator(double[] array)
Spliterator.OfDouble covering all of the specified
array.
The spliterator reports Spliterator.SIZED,
Spliterator.SUBSIZED, Spliterator.ORDERED, and
Spliterator.IMMUTABLE.
array - the array, assumed to be unmodified during usepublic static Spliterator.OfDouble spliterator(double[] array, int startInclusive, int endExclusive)
Spliterator.OfDouble covering the specified range of
the specified array.
The spliterator reports Spliterator.SIZED,
Spliterator.SUBSIZED, Spliterator.ORDERED, and
Spliterator.IMMUTABLE.
array - the array, assumed to be unmodified during usestartInclusive - the first index to cover, inclusiveendExclusive - index immediately past the last index to coverArrayIndexOutOfBoundsException - if startInclusive is
negative, endExclusive is less than
startInclusive, or endExclusive is greater than
the array sizepublic static <T> Stream<T> stream(T[] array)
Stream with the specified array as its
source.T - The type of the array elementsarray - The array, assumed to be unmodified during useStream for the arraypublic static <T> Stream<T> stream(T[] array, int startInclusive, int endExclusive)
Stream with the specified range of the
specified array as its source.T - the type of the array elementsarray - the array, assumed to be unmodified during usestartInclusive - the first index to cover, inclusiveendExclusive - index immediately past the last index to coverStream for the array rangeArrayIndexOutOfBoundsException - if startInclusive is
negative, endExclusive is less than
startInclusive, or endExclusive is greater than
the array sizepublic static IntStream stream(int[] array)
IntStream with the specified array as its
source.array - the array, assumed to be unmodified during useIntStream for the arraypublic static IntStream stream(int[] array, int startInclusive, int endExclusive)
IntStream with the specified range of the
specified array as its source.array - the array, assumed to be unmodified during usestartInclusive - the first index to cover, inclusiveendExclusive - index immediately past the last index to coverIntStream for the array rangeArrayIndexOutOfBoundsException - if startInclusive is
negative, endExclusive is less than
startInclusive, or endExclusive is greater than
the array sizepublic static LongStream stream(long[] array)
LongStream with the specified array as its
source.array - the array, assumed to be unmodified during useLongStream for the arraypublic static LongStream stream(long[] array, int startInclusive, int endExclusive)
LongStream with the specified range of the
specified array as its source.array - the array, assumed to be unmodified during usestartInclusive - the first index to cover, inclusiveendExclusive - index immediately past the last index to coverLongStream for the array rangeArrayIndexOutOfBoundsException - if startInclusive is
negative, endExclusive is less than
startInclusive, or endExclusive is greater than
the array sizepublic static DoubleStream stream(double[] array)
DoubleStream with the specified array as its
source.array - the array, assumed to be unmodified during useDoubleStream for the arraypublic static DoubleStream stream(double[] array, int startInclusive, int endExclusive)
DoubleStream with the specified range of the
specified array as its source.array - the array, assumed to be unmodified during usestartInclusive - the first index to cover, inclusiveendExclusive - index immediately past the last index to coverDoubleStream for the array rangeArrayIndexOutOfBoundsException - if startInclusive is
negative, endExclusive is less than
startInclusive, or endExclusive is greater than
the array size