public class Arrays
- Object
- Arrays
Arrays contains static methods which operate on arrays.Methods
Inherited methods
Method details
asList
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.Parameters
arrayT...- the array.
Returns
List of the elements of the specified array.binarySearch
public static int binarySearch(byte[] array, byte value)Parameters
arraybyte[]- the sorted
bytearray to search. valuebyte- the
byteelement to find.
Returns
-index - 1 where the element would be inserted.binarySearch
public static int binarySearch(char[] array, char value)Parameters
arraychar[]- the sorted char array to search
valuechar- the char element to find
Returns
binarySearch
public static int binarySearch(double[] array, double value)Parameters
arraydouble[]- the sorted double array to search
valuedouble- the double element to find
Returns
binarySearch
public static int binarySearch(float[] array, float value)Parameters
arrayfloat[]- the sorted float array to search
valuefloat- the float element to find
Returns
binarySearch
public static int binarySearch(int[] array, int value)Parameters
arrayint[]- the sorted int array to search
valueint- the int element to find
Returns
binarySearch
public static int binarySearch(long[] array, long value)Parameters
arraylong[]- the sorted long array to search
valuelong- the long element to find
Returns
binarySearch
public static int binarySearch(Object[] array, Object object)Parameters
arrayObject[]- the sorted Object array to search
objectObject- the Object element to find
Returns
Throws
ClassCastException- when an element in the array or the search element does not implement Comparable, or cannot be compared to each other
binarySearch
public static <T> int binarySearch(T[] array, T object, Comparator<? super T> comparator)Performs a binary search for the specified element in the specified sorted array using the Comparator to compare elements.
Type parameter T: type of object
Parameters
arrayT[]- the sorted Object array to search
objectT- the char element to find
comparatorComparator<? super T>- the Comparator
Returns
Throws
ClassCastException- when an element in the array and the search element cannot be compared to each other using the Comparator
binarySearch
public static int binarySearch(short[] array, short value)Parameters
arrayshort[]- the sorted short array to search
valueshort- the short element to find
Returns
binarySearch
public static int binarySearch(byte[] array, int startIndex, int endIndex, byte value)Parameters
arraybyte[]- the sorted byte array to search
startIndexint- the inclusive start index
endIndexint- the exclusive end index
valuebyte- the byte element to find
Returns
Throws
IllegalArgumentExceptionif startIndex is bigger than endIndex
ArrayIndexOutOfBoundsExceptionif startIndex is smaller than zero or or endIndex is bigger than length of array
binarySearch
public static int binarySearch(char[] array, int startIndex, int endIndex, char value)Parameters
arraychar[]- the sorted char array to search
startIndexint- the inclusive start index
endIndexint- the exclusive end index
valuechar- the char element to find
Returns
Throws
IllegalArgumentExceptionif startIndex is bigger than endIndex
ArrayIndexOutOfBoundsExceptionif startIndex is smaller than zero or or endIndex is bigger than length of array
binarySearch
public static int binarySearch(double[] array, int startIndex, int endIndex, double value)Parameters
arraydouble[]- the sorted double array to search
startIndexint- the inclusive start index
endIndexint- the exclusive end index
valuedouble- the double element to find
Returns
Throws
IllegalArgumentExceptionif startIndex is bigger than endIndex
ArrayIndexOutOfBoundsExceptionif startIndex is smaller than zero or or endIndex is bigger than length of array
binarySearch
public static int binarySearch(float[] array, int startIndex, int endIndex, float value)Parameters
arrayfloat[]- the sorted float array to search
startIndexint- the inclusive start index
endIndexint- the exclusive end index
valuefloat- the float element to find
Returns
Throws
IllegalArgumentExceptionif startIndex is bigger than endIndex
ArrayIndexOutOfBoundsExceptionif startIndex is smaller than zero or or endIndex is bigger than length of array
binarySearch
public static int binarySearch(int[] array, int startIndex, int endIndex, int value)Parameters
arrayint[]- the sorted int array to search
startIndexint- the inclusive start index
endIndexint- the exclusive end index
valueint- the int element to find
Returns
Throws
IllegalArgumentExceptionif startIndex is bigger than endIndex
ArrayIndexOutOfBoundsExceptionif startIndex is smaller than zero or or endIndex is bigger than length of array
binarySearch
public static int binarySearch(long[] array, int startIndex, int endIndex, long value)Parameters
arraylong[]- the sorted long array to search
startIndexint- the inclusive start index
endIndexint- the exclusive end index
valuelong- the long element to find
Returns
Throws
IllegalArgumentExceptionif startIndex is bigger than endIndex
ArrayIndexOutOfBoundsExceptionif startIndex is smaller than zero or or endIndex is bigger than length of array
binarySearch
public static int binarySearch(Object[] array, int startIndex, int endIndex, Object object)Parameters
arrayObject[]- the sorted Object array to search
startIndexint- the inclusive start index
endIndexint- the exclusive end index
objectObject- the object element to find
Returns
Throws
ClassCastException- when an element in the array or the search element does not implement Comparable, or cannot be compared to each other
IllegalArgumentExceptionif startIndex is bigger than endIndex
ArrayIndexOutOfBoundsExceptionif startIndex is smaller than zero or or endIndex is bigger than length of array
binarySearch
public static <T> int binarySearch(T[] array, int startIndex, int endIndex, T object, Comparator<? super T> comparator)Performs a binary search for the specified element in a part of the specified sorted array using the Comparator to compare elements.
Type parameter T: type of object
Parameters
arrayT[]- the sorted Object array to search
startIndexint- the inclusive start index
endIndexint- the exclusive end index
objectT- the value element to find
comparatorComparator<? super T>- the Comparator
Returns
Throws
ClassCastException- when an element in the array and the search element cannot be compared to each other using the Comparator
IllegalArgumentExceptionif startIndex is bigger than endIndex
ArrayIndexOutOfBoundsExceptionif startIndex is smaller than zero or or endIndex is bigger than length of array
binarySearch
public static int binarySearch(short[] array, int startIndex, int endIndex, short value)Parameters
arrayshort[]- the sorted short array to search
startIndexint- the inclusive start index
endIndexint- the exclusive end index
valueshort- the short element to find
Returns
Throws
IllegalArgumentExceptionif startIndex is bigger than endIndex
ArrayIndexOutOfBoundsExceptionif startIndex is smaller than zero or or endIndex is bigger than length of array
fill
public static void fill(byte[] array, byte value)Parameters
arraybyte[]- the
bytearray to fill. valuebyte- the
byteelement.
fill
public static void fill(byte[] array, int start, int end, byte value)Parameters
arraybyte[]- the
bytearray to fill. startint- the first index to fill.
endint- the last + 1 index to fill.
valuebyte- the
byteelement.
Throws
IllegalArgumentException- if
start > end. ArrayIndexOutOfBoundsException- if
start array.length.
fill
public static void fill(short[] array, short value)Parameters
arrayshort[]- the
shortarray to fill. valueshort- the
shortelement.
fill
public static void fill(short[] array, int start, int end, short value)Parameters
arrayshort[]- the
shortarray to fill. startint- the first index to fill.
endint- the last + 1 index to fill.
valueshort- the
shortelement.
Throws
IllegalArgumentException- if
start > end. ArrayIndexOutOfBoundsException- if
start array.length.
fill
public static void fill(char[] array, char value)Parameters
arraychar[]- the
chararray to fill. valuechar- the
charelement.
fill
public static void fill(char[] array, int start, int end, char value)Parameters
arraychar[]- the
chararray to fill. startint- the first index to fill.
endint- the last + 1 index to fill.
valuechar- the
charelement.
Throws
IllegalArgumentException- if
start > end. ArrayIndexOutOfBoundsException- if
start array.length.
fill
public static void fill(int[] array, int value)Parameters
arrayint[]- the
intarray to fill. valueint- the
intelement.
fill
public static void fill(int[] array, int start, int end, int value)Parameters
arrayint[]- the
intarray to fill. startint- the first index to fill.
endint- the last + 1 index to fill.
valueint- the
intelement.
Throws
IllegalArgumentException- if
start > end. ArrayIndexOutOfBoundsException- if
start array.length.
fill
public static void fill(long[] array, long value)Parameters
arraylong[]- the
longarray to fill. valuelong- the
longelement.
fill
public static void fill(long[] array, int start, int end, long value)Parameters
arraylong[]- the
longarray to fill. startint- the first index to fill.
endint- the last + 1 index to fill.
valuelong- the
longelement.
Throws
IllegalArgumentException- if
start > end. ArrayIndexOutOfBoundsException- if
start array.length.
fill
public static void fill(float[] array, float value)Parameters
arrayfloat[]- the
floatarray to fill. valuefloat- the
floatelement.
fill
public static void fill(float[] array, int start, int end, float value)Parameters
arrayfloat[]- the
floatarray to fill. startint- the first index to fill.
endint- the last + 1 index to fill.
valuefloat- the
floatelement.
Throws
IllegalArgumentException- if
start > end. ArrayIndexOutOfBoundsException- if
start array.length.
fill
public static void fill(double[] array, double value)Parameters
arraydouble[]- the
doublearray to fill. valuedouble- the
doubleelement.
fill
public static void fill(double[] array, int start, int end, double value)Parameters
arraydouble[]- the
doublearray to fill. startint- the first index to fill.
endint- the last + 1 index to fill.
valuedouble- the
doubleelement.
Throws
IllegalArgumentException- if
start > end. ArrayIndexOutOfBoundsException- if
start array.length.
fill
public static void fill(boolean[] array, boolean value)Parameters
arrayboolean[]- the
booleanarray to fill. valueboolean- the
booleanelement.
fill
public static void fill(boolean[] array, int start, int end, boolean value)Parameters
arrayboolean[]- the
booleanarray to fill. startint- the first index to fill.
endint- the last + 1 index to fill.
valueboolean- the
booleanelement.
Throws
IllegalArgumentException- if
start > end. ArrayIndexOutOfBoundsException- if
start array.length.
fill
public static void fill(Object[] array, Object value)Parameters
arrayObject[]- the
Objectarray to fill. valueObject- the
Objectelement.
fill
public static void fill(Object[] array, int start, int end, Object value)Parameters
arrayObject[]- the
Objectarray to fill. startint- the first index to fill.
endint- the last + 1 index to fill.
valueObject- the
Objectelement.
Throws
IllegalArgumentException- if
start > end. ArrayIndexOutOfBoundsException- if
start array.length.
hashCode
public static int hashCode(boolean[] array)Returns a hash code based on the contents of the given array. For any two
boolean arrays a and b, if
Arrays.equals(a, b) returns true, it means
that the return value of Arrays.hashCode(a) equals Arrays.hashCode(b).
The value returned by this method is the same value as the
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.
Parameters
arrayboolean[]- the array whose hash code to compute.
Returns
array.hashCode
public static int hashCode(int[] array)Returns a hash code based on the contents of the given array. For any two
not-null int arrays a and b, if
Arrays.equals(a, b) returns true, it means
that the return value of Arrays.hashCode(a) equals Arrays.hashCode(b).
The value returned by this method is the same value as the
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.
Parameters
arrayint[]- the array whose hash code to compute.
Returns
array.hashCode
public static int hashCode(short[] array)Returns a hash code based on the contents of the given array. For any two
short arrays a and b, if
Arrays.equals(a, b) returns true, it means
that the return value of Arrays.hashCode(a) equals Arrays.hashCode(b).
The value returned by this method is the same value as the
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.
Parameters
arrayshort[]- the array whose hash code to compute.
Returns
array.hashCode
public static int hashCode(char[] array)Returns a hash code based on the contents of the given array. For any two
char arrays a and b, if
Arrays.equals(a, b) returns true, it means
that the return value of Arrays.hashCode(a) equals Arrays.hashCode(b).
The value returned by this method is the same value as the
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.
Parameters
arraychar[]- the array whose hash code to compute.
Returns
array.hashCode
public static int hashCode(byte[] array)Returns a hash code based on the contents of the given array. For any two
byte arrays a and b, if
Arrays.equals(a, b) returns true, it means
that the return value of Arrays.hashCode(a) equals Arrays.hashCode(b).
The value returned by this method is the same value as the
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.
Parameters
arraybyte[]- the array whose hash code to compute.
Returns
array.hashCode
public static int hashCode(long[] array)Returns a hash code based on the contents of the given array. For any two
long arrays a and b, if
Arrays.equals(a, b) returns true, it means
that the return value of Arrays.hashCode(a) equals Arrays.hashCode(b).
The value returned by this method is the same value as the
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.
Parameters
arraylong[]- the array whose hash code to compute.
Returns
array.hashCode
public static int hashCode(float[] array)Returns a hash code based on the contents of the given array. For any two
float arrays a and b, if
Arrays.equals(a, b) returns true, it means
that the return value of Arrays.hashCode(a) equals Arrays.hashCode(b).
The value returned by this method is the same value as the
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.
Parameters
arrayfloat[]- the array whose hash code to compute.
Returns
array.hashCode
public static int hashCode(double[] array)Returns a hash code based on the contents of the given array. For any two
double arrays a and b, if
Arrays.equals(a, b) returns true, it means
that the return value of Arrays.hashCode(a) equals Arrays.hashCode(b).
The value returned by this method is the same value as the
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.
Parameters
arraydouble[]- the array whose hash code to compute.
Returns
array.hashCode
public static int hashCode(Object[] array)Returns a hash code based on the contents of the given array. If the array contains other arrays as its elements, the hash code is based on their identities not their contents. So it is acceptable to invoke this method on an array that contains itself as an element, either directly or indirectly.
For any two arrays a and b, if
Arrays.equals(a, b) returns true, it means
that the return value of Arrays.hashCode(a) equals
Arrays.hashCode(b).
The value returned by this method is the same value as the method
Arrays.asList(array).hashCode(). If the array is null, the return value
is 0.
Parameters
arrayObject[]- the array whose hash code to compute.
Returns
array.deepHashCode
public static int deepHashCode(Object[] array)Returns a hash code based on the “deep contents” of the given array. If the array contains other arrays as its elements, the hash code is based on their contents not their identities. So it is not acceptable to invoke this method on an array that contains itself as an element, either directly or indirectly.
For any two arrays a and b, if
Arrays.deepEquals(a, b) returns true, it
means that the return value of Arrays.deepHashCode(a) equals
Arrays.deepHashCode(b).
The computation of the value returned by this method is similar to that
of the value returned by 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.
Parameters
arrayObject[]- the array whose hash code to compute.
Returns
array.equals
public static boolean equals(byte[] array1, byte[] array2)Parameters
array1byte[]- the first
bytearray. array2byte[]- the second
bytearray.
Returns
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.equals
public static boolean equals(short[] array1, short[] array2)Parameters
array1short[]- the first
shortarray. array2short[]- the second
shortarray.
Returns
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.equals
public static boolean equals(char[] array1, char[] array2)Parameters
array1char[]- the first
chararray. array2char[]- the second
chararray.
Returns
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.equals
public static boolean equals(int[] array1, int[] array2)Parameters
array1int[]- the first
intarray. array2int[]- the second
intarray.
Returns
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.equals
public static boolean equals(long[] array1, long[] array2)Parameters
array1long[]- the first
longarray. array2long[]- the second
longarray.
Returns
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.equals
public static boolean equals(float[] array1, float[] array2)Float.equals().Parameters
array1float[]- the first
floatarray. array2float[]- the second
floatarray.
Returns
true if both arrays are null or if the arrays have the
same length and the elements at each index in the two arrays are
equal, false otherwise.See also
equals
public static boolean equals(double[] array1, double[] array2)Double.equals().Parameters
array1double[]- the first
doublearray. array2double[]- the second
doublearray.
Returns
true if both arrays are null or if the arrays have the
same length and the elements at each index in the two arrays are
equal, false otherwise.See also
equals
public static boolean equals(boolean[] array1, boolean[] array2)Parameters
array1boolean[]- the first
booleanarray. array2boolean[]- the second
booleanarray.
Returns
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.equals
public static boolean equals(Object[] array1, Object[] array2)Parameters
array1Object[]- the first
Objectarray. array2Object[]- the second
Objectarray.
Returns
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.deepEquals
public static boolean deepEquals(Object[] array1, Object[] array2)Returns true if the two given arrays are deeply equal to one another.
Unlike the method equals(Object[] array1, Object[] array2), this method
is appropriate for use for nested arrays of arbitrary depth.
Two array references are considered deeply equal if they are both null,
or if they refer to arrays that have the same length and the elements at
each index in the two arrays are equal.
Two null elements element1 and element2 are possibly deeply equal if any
of the following conditions satisfied:
element1 and element2 are both arrays of object reference types, and
Arrays.deepEquals(element1, element2) would return true.
element1 and element2 are arrays of the same primitive type, and the
appropriate overloading of Arrays.equals(element1, element2) would return
true.
element1 == element2
element1.equals(element2) would return true.
Note that this definition permits null elements at any depth.
If either of the given arrays contain themselves as elements, the behavior of this method is uncertain.
Parameters
array1Object[]- the first
Objectarray. array2Object[]- the second
Objectarray.
Returns
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.sort
public static void sort(byte[] array)Parameters
arraybyte[]- the
bytearray to be sorted.
sort
public static void sort(byte[] array, int start, int end)Parameters
arraybyte[]- the
bytearray to be sorted. startint- the start index to sort.
endint- the last + 1 index to sort.
Throws
IllegalArgumentException- if
start > end. ArrayIndexOutOfBoundsException- if
start array.length.
sort
public static void sort(char[] array)Parameters
arraychar[]- the
chararray to be sorted.
sort
public static void sort(char[] array, int start, int end)Parameters
arraychar[]- the
chararray to be sorted. startint- the start index to sort.
endint- the last + 1 index to sort.
Throws
IllegalArgumentException- if
start > end. ArrayIndexOutOfBoundsException- if
start array.length.
sort
public static void sort(double[] array)Parameters
arraydouble[]- the
doublearray to be sorted.
See also
sort
public static void sort(double[] array, int start, int end)Double.compareTo().Parameters
arraydouble[]- the
doublearray to be sorted. startint- the start index to sort.
endint- the last + 1 index to sort.
Throws
IllegalArgumentException- if
start > end. ArrayIndexOutOfBoundsException- if
start array.length.
See also
sort
public static void sort(float[] array)Parameters
arrayfloat[]- the
floatarray to be sorted.
See also
sort
public static void sort(float[] array, int start, int end)Float.compareTo().Parameters
arrayfloat[]- the
floatarray to be sorted. startint- the start index to sort.
endint- the last + 1 index to sort.
Throws
IllegalArgumentException- if
start > end. ArrayIndexOutOfBoundsException- if
start array.length.
See also
sort
public static void sort(int[] array)Parameters
arrayint[]- the
intarray to be sorted.
sort
public static void sort(int[] array, int start, int end)Parameters
arrayint[]- the
intarray to be sorted. startint- the start index to sort.
endint- the last + 1 index to sort.
Throws
IllegalArgumentException- if
start > end. ArrayIndexOutOfBoundsException- if
start array.length.
sort
public static void sort(long[] array)Parameters
arraylong[]- the
longarray to be sorted.
sort
public static void sort(long[] array, int start, int end)Parameters
arraylong[]- the
longarray to be sorted. startint- the start index to sort.
endint- the last + 1 index to sort.
Throws
IllegalArgumentException- if
start > end. ArrayIndexOutOfBoundsException- if
start array.length.
sort
public static void sort(Object[] array)Parameters
arrayObject[]- the
Objectarray to be sorted.
Throws
ClassCastException- if an element in the array does not implement
Comparableor if some elements cannot be compared to each other.
See also
sort
public static void sort(Object[] array, int start, int end)Comparable interface and must be
comparable to each other without a ClassCastException being
thrown.Parameters
arrayObject[]- the
Objectarray to be sorted. startint- the start index to sort.
endint- the last + 1 index to sort.
Throws
ClassCastException- if an element in the array does not implement
Comparableor some elements cannot be compared to each other. IllegalArgumentException- if
start > end. ArrayIndexOutOfBoundsException- if
start array.length.
sort
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.Parameters
arrayT[]- the
Objectarray to be sorted. startint- the start index to sort.
endint- the last + 1 index to sort.
comparatorComparator<? super T>- the
Comparator.
Throws
ClassCastException- if elements in the array cannot be compared to each other
using the
Comparator. IllegalArgumentException- if
start > end. ArrayIndexOutOfBoundsException- if
start array.length.
sort
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.Parameters
arrayT[]- the
Objectarray to be sorted. comparatorComparator<? super T>- the
Comparator.
Throws
ClassCastException- if elements in the array cannot be compared to each other
using the
Comparator.
sort
public static void sort(short[] array)Parameters
arrayshort[]- the
shortarray to be sorted.
sort
public static void sort(short[] array, int start, int end)Parameters
arrayshort[]- the
shortarray to be sorted. startint- the start index to sort.
endint- the last + 1 index to sort.
Throws
IllegalArgumentException- if
start > end. ArrayIndexOutOfBoundsException- if
start array.length.
toString
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.Parameters
arrayboolean[]- the
booleanarray to convert.
Returns
String representation of array.toString
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.Parameters
arraybyte[]- the
bytearray to convert.
Returns
String representation of array.toString
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.Parameters
arraychar[]- the
chararray to convert.
Returns
String representation of array.toString
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.Parameters
arraydouble[]- the
doublearray to convert.
Returns
String representation of array.toString
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.Parameters
arrayfloat[]- the
floatarray to convert.
Returns
String representation of array.toString
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.Parameters
arrayint[]- the
intarray to convert.
Returns
String representation of array.toString
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.Parameters
arraylong[]- the
longarray to convert.
Returns
String representation of array.toString
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.Parameters
arrayshort[]- the
shortarray to convert.
Returns
String representation of array.toString
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.Parameters
arrayObject[]- the
Objectarray to convert.
Returns
String representation of array.deepToString
public 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.
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.
Parameters
arrayObject[]- the
Objectarray to convert.
Returns
String representation of array.copyOfRange
public static boolean[] copyOfRange(boolean[] original, int start, int end)from], and other elements in the new array are in the
original order. The padding value whose index is bigger than or equal to
original.length - start is false.Parameters
originalboolean[]- the original array
startint- the start index, inclusive
endint- the end index, exclusive, may bigger than length of the array
Returns
Throws
ArrayIndexOutOfBoundsException- if start is smaller than 0 or bigger than original.length
IllegalArgumentException- if start is bigger than end
NullPointerException- if original is null
copyOfRange
public static byte[] copyOfRange(byte[] original, int start, int end)from], and other elements in the new array are in the
original order. The padding value whose index is bigger than or equal to
original.length - start is (byte)0.Parameters
originalbyte[]- the original array
startint- the start index, inclusive
endint- the end index, exclusive, may bigger than length of the array
Returns
Throws
ArrayIndexOutOfBoundsException- if start is smaller than 0 or bigger than original.length
IllegalArgumentException- if start is bigger than end
NullPointerException- if original is null
copyOfRange
public static char[] copyOfRange(char[] original, int start, int end)from], and other elements in the new array are in the
original order. The padding value whose index is bigger than or equal to
original.length - start is ‘\u000’.Parameters
originalchar[]- the original array
startint- the start index, inclusive
endint- the end index, exclusive, may bigger than length of the array
Returns
Throws
ArrayIndexOutOfBoundsException- if start is smaller than 0 or bigger than original.length
IllegalArgumentException- if start is bigger than end
NullPointerException- if original is null
copyOfRange
public static double[] copyOfRange(double[] original, int start, int end)from], and other elements in the new array are in the
original order. The padding value whose index is bigger than or equal to
original.length - start is 0d.Parameters
originaldouble[]- the original array
startint- the start index, inclusive
endint- the end index, exclusive, may bigger than length of the array
Returns
Throws
ArrayIndexOutOfBoundsException- if start is smaller than 0 or bigger than original.length
IllegalArgumentException- if start is bigger than end
NullPointerException- if original is null
copyOfRange
public static float[] copyOfRange(float[] original, int start, int end)from], and other elements in the new array are in the
original order. The padding value whose index is bigger than or equal to
original.length - start is 0f.Parameters
originalfloat[]- the original array
startint- the start index, inclusive
endint- the end index, exclusive, may bigger than length of the array
Returns
Throws
ArrayIndexOutOfBoundsException- if start is smaller than 0 or bigger than original.length
IllegalArgumentException- if start is bigger than end
NullPointerException- if original is null
copyOfRange
public static int[] copyOfRange(int[] original, int start, int end)from], and other elements in the new array are in the
original order. The padding value whose index is bigger than or equal to
original.length - start is 0.Parameters
originalint[]- the original array
startint- the start index, inclusive
endint- the end index, exclusive, may bigger than length of the array
Returns
Throws
ArrayIndexOutOfBoundsException- if start is smaller than 0 or bigger than original.length
IllegalArgumentException- if start is bigger than end
NullPointerException- if original is null
copyOfRange
public static long[] copyOfRange(long[] original, int start, int end)from], and other elements in the new array are in the
original order. The padding value whose index is bigger than or equal to
original.length - start is 0L.Parameters
originallong[]- the original array
startint- the start index, inclusive
endint- the end index, exclusive, may bigger than length of the array
Returns
Throws
ArrayIndexOutOfBoundsException- if start is smaller than 0 or bigger than original.length
IllegalArgumentException- if start is bigger than end
NullPointerException- if original is null
copyOfRange
public static short[] copyOfRange(short[] original, int start, int end)from], and other elements in the new array are in the
original order. The padding value whose index is bigger than or equal to
original.length - start is (short)0.Parameters
originalshort[]- the original array
startint- the start index, inclusive
endint- the end index, exclusive, may bigger than length of the array
Returns
Throws
ArrayIndexOutOfBoundsException- if start is smaller than 0 or bigger than original.length
IllegalArgumentException- if start is bigger than end
NullPointerException- if original is null
copyOfRange
public static <T, U> T[] copyOfRange(U[] original, int from, int to, Class<? extends T[]> newType)copyOfRange
public static <T> T[] copyOfRange(T[] original, int from, int to)copyOf
public static <T> T[] copyOf(T[] original, int newLength, Class<? extends T[]> newType)copyOf
public static <T> T[] copyOf(T[] original, int newLength)copyOf
public static boolean[] copyOf(boolean[] original, int newlen)copyOf
public static char[] copyOf(char[] original, int newlen)copyOf
public static double[] copyOf(double[] original, int newlen)copyOf
public static float[] copyOf(float[] original, int newlen)copyOf
public static long[] copyOf(long[] original, int newlen)copyOf
public static int[] copyOf(int[] original, int newlen)copyOf
public static byte[] copyOf(byte[] original, int newlen)copyOf
public static short[] copyOf(short[] original, int len)