public class ArrayX extends Object implements ArrayConst
EMPTY_BOOLEAN_ARRAY, EMPTY_BOOLEAN_OBJECT_ARRAY, EMPTY_BYTE_ARRAY, EMPTY_BYTE_OBJECT_ARRAY, EMPTY_CHAR_ARRAY, EMPTY_CHARACTER_OBJECT_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_DOUBLE_ARRAY, EMPTY_DOUBLE_OBJECT_ARRAY, EMPTY_FLOAT_ARRAY, EMPTY_FLOAT_OBJECT_ARRAY, EMPTY_INT_ARRAY, EMPTY_INTEGER_OBJECT_ARRAY, EMPTY_LONG_ARRAY, EMPTY_LONG_OBJECT_ARRAY, EMPTY_OBJECT_ARRAY, EMPTY_SHORT_ARRAY, EMPTY_SHORT_OBJECT_ARRAY, EMPTY_STRING_ARRAY, INDEX_NOT_FOUND| 构造器和说明 |
|---|
ArrayX() |
| 限定符和类型 | 方法和说明 |
|---|---|
boolean[] |
add(boolean[] array,
boolean element)
Copies the given array and adds the given element at the end of the new array.
|
byte[] |
add(byte[] array,
byte element)
Copies the given array and adds the given element at the end of the new array.
|
byte[] |
add(byte[] array,
int index,
byte element)
Inserts the specified element at the specified position in the array.
|
char[] |
add(char[] array,
char element)
Copies the given array and adds the given element at the end of the new array.
|
char[] |
add(char[] array,
int index,
char element)
Inserts the specified element at the specified position in the array.
|
double[] |
add(double[] array,
double element)
Copies the given array and adds the given element at the end of the new array.
|
double[] |
add(double[] array,
int index,
double element)
Inserts the specified element at the specified position in the array.
|
float[] |
add(float[] array,
float element)
Copies the given array and adds the given element at the end of the new array.
|
float[] |
add(float[] array,
int index,
float element)
Inserts the specified element at the specified position in the array.
|
int[] |
add(int[] array,
int element)
Copies the given array and adds the given element at the end of the new array.
|
int[] |
add(int[] array,
int index,
int element)
Inserts the specified element at the specified position in the array.
|
long[] |
add(long[] array,
int index,
long element)
Inserts the specified element at the specified position in the array.
|
long[] |
add(long[] array,
long element)
Copies the given array and adds the given element at the end of the new array.
|
Object[] |
add(Object[] array,
int index,
Object element)
Inserts the specified element at the specified position in the array.
|
Object[] |
add(Object[] array,
Object element)
Copies the given array and adds the given element at the end of the new array.
|
short[] |
add(short[] array,
int index,
short element)
Inserts the specified element at the specified position in the array.
|
short[] |
add(short[] array,
short element)
Copies the given array and adds the given element at the end of the new array.
|
boolean[] |
addAll(boolean[] array1,
boolean[] array2)
Adds all the elements of the given arrays into a new array.
|
byte[] |
addAll(byte[] array1,
byte[] array2)
Adds all the elements of the given arrays into a new array.
|
char[] |
addAll(char[] array1,
char[] array2)
Adds all the elements of the given arrays into a new array.
|
double[] |
addAll(double[] array1,
double[] array2)
Adds all the elements of the given arrays into a new array.
|
float[] |
addAll(float[] array1,
float[] array2)
Adds all the elements of the given arrays into a new array.
|
int[] |
addAll(int[] array1,
int[] array2)
Adds all the elements of the given arrays into a new array.
|
long[] |
addAll(long[] array1,
long[] array2)
Adds all the elements of the given arrays into a new array.
|
Object[] |
addAll(Object[] array1,
Object[] array2)
Adds all the elements of the given arrays into a new array.
|
short[] |
addAll(short[] array1,
short[] array2)
Adds all the elements of the given arrays into a new array.
|
<T> T[] |
addAll(T[]... arrays)
将多个数组合并在一起
忽略null的数组 |
boolean[] |
clone(boolean[] array)
Clones an array returning a typecast result and handling
null. |
byte[] |
clone(byte[] array)
Clones an array returning a typecast result and handling
null. |
char[] |
clone(char[] array)
Clones an array returning a typecast result and handling
null. |
double[] |
clone(double[] array)
Clones an array returning a typecast result and handling
null. |
float[] |
clone(float[] array)
Clones an array returning a typecast result and handling
null. |
int[] |
clone(int[] array)
Clones an array returning a typecast result and handling
null. |
long[] |
clone(long[] array)
Clones an array returning a typecast result and handling
null. |
Object[] |
clone(Object[] array)
Shallow clones an array returning a typecast result and handling
null. |
short[] |
clone(short[] array)
Clones an array returning a typecast result and handling
null. |
boolean |
contains(boolean[] array,
boolean valueToFind)
Checks if the value is in the given array.
|
boolean |
contains(byte[] array,
byte valueToFind)
Checks if the value is in the given array.
|
boolean |
contains(char[] array,
char valueToFind)
Checks if the value is in the given array.
|
boolean |
contains(double[] array,
double valueToFind)
Checks if the value is in the given array.
|
boolean |
contains(double[] array,
double valueToFind,
double tolerance)
Checks if a value falling within the given tolerance is in the
given array.
|
boolean |
contains(float[] array,
float valueToFind)
Checks if the value is in the given array.
|
boolean |
contains(int[] array,
int valueToFind)
Checks if the value is in the given array.
|
boolean |
contains(long[] array,
long valueToFind)
Checks if the value is in the given array.
|
boolean |
contains(Object[] array,
Object objectToFind)
Checks if the object is in the given array.
|
boolean |
contains(short[] array,
short valueToFind)
Checks if the value is in the given array.
|
int |
getLength(Object array)
Returns the length of the specified array.
|
int |
indexOf(boolean[] array,
boolean valueToFind)
Finds the index of the given value in the array.
|
int |
indexOf(boolean[] array,
boolean valueToFind,
int startIndex)
Finds the index of the given value in the array starting at the given index.
|
int |
indexOf(byte[] array,
byte valueToFind)
Finds the index of the given value in the array.
|
int |
indexOf(byte[] array,
byte valueToFind,
int startIndex)
Finds the index of the given value in the array starting at the given index.
|
int |
indexOf(char[] array,
char valueToFind)
Finds the index of the given value in the array.
|
int |
indexOf(char[] array,
char valueToFind,
int startIndex)
Finds the index of the given value in the array starting at the given index.
|
int |
indexOf(double[] array,
double valueToFind)
Finds the index of the given value in the array.
|
int |
indexOf(double[] array,
double valueToFind,
double tolerance)
Finds the index of the given value within a given tolerance in the array.
|
int |
indexOf(double[] array,
double valueToFind,
int startIndex)
Finds the index of the given value in the array starting at the given index.
|
int |
indexOf(double[] array,
double valueToFind,
int startIndex,
double tolerance)
Finds the index of the given value in the array starting at the given index.
|
int |
indexOf(float[] array,
float valueToFind)
Finds the index of the given value in the array.
|
int |
indexOf(float[] array,
float valueToFind,
int startIndex)
Finds the index of the given value in the array starting at the given index.
|
int |
indexOf(int[] array,
int valueToFind)
Finds the index of the given value in the array.
|
int |
indexOf(int[] array,
int valueToFind,
int startIndex)
Finds the index of the given value in the array starting at the given index.
|
int |
indexOf(long[] array,
long valueToFind)
Finds the index of the given value in the array.
|
int |
indexOf(long[] array,
long valueToFind,
int startIndex)
Finds the index of the given value in the array starting at the given index.
|
int |
indexOf(Object[] array,
Object objectToFind)
Finds the index of the given object in the array.
|
int |
indexOf(Object[] array,
Object objectToFind,
int startIndex)
Finds the index of the given object in the array starting at the given index.
|
int |
indexOf(short[] array,
short valueToFind)
Finds the index of the given value in the array.
|
int |
indexOf(short[] array,
short valueToFind,
int startIndex)
Finds the index of the given value in the array starting at the given index.
|
boolean |
isArray(Object obj)
对象是否为数组对象
|
boolean |
isEmpty(boolean[] array)
Checks if an array of primitive booleans is empty or
null. |
boolean |
isEmpty(byte[] array)
Checks if an array of primitive bytes is empty or
null. |
boolean |
isEmpty(char[] array)
Checks if an array of primitive chars is empty or
null. |
boolean |
isEmpty(double[] array)
Checks if an array of primitive doubles is empty or
null. |
boolean |
isEmpty(float[] array)
Checks if an array of primitive floats is empty or
null. |
boolean |
isEmpty(int[] array)
Checks if an array of primitive ints is empty or
null. |
boolean |
isEmpty(long[] array)
Checks if an array of primitive longs is empty or
null. |
boolean |
isEmpty(Object[] array)
Checks if an array of Objects is empty or
null. |
boolean |
isEmpty(short[] array)
Checks if an array of primitive shorts is empty or
null. |
boolean |
isNotEmpty(boolean[] array)
Checks if an array of primitive booleans is not empty or not
null. |
boolean |
isNotEmpty(byte[] array)
Checks if an array of primitive bytes is not empty or not
null. |
boolean |
isNotEmpty(char[] array)
Checks if an array of primitive chars is not empty or not
null. |
boolean |
isNotEmpty(double[] array)
Checks if an array of primitive doubles is not empty or not
null. |
boolean |
isNotEmpty(float[] array)
Checks if an array of primitive floats is not empty or not
null. |
boolean |
isNotEmpty(int[] array)
Checks if an array of primitive ints is not empty or not
null. |
boolean |
isNotEmpty(long[] array)
Checks if an array of primitive longs is not empty or not
null. |
boolean |
isNotEmpty(Object[] array)
Checks if an array of Objects is not empty or not
null. |
boolean |
isNotEmpty(short[] array)
Checks if an array of primitive shorts is not empty or not
null. |
boolean |
isSameLength(boolean[] array1,
boolean[] array2)
Checks whether two arrays are the same length, treating
null arrays as length 0. |
boolean |
isSameLength(byte[] array1,
byte[] array2)
Checks whether two arrays are the same length, treating
null arrays as length 0. |
boolean |
isSameLength(char[] array1,
char[] array2)
Checks whether two arrays are the same length, treating
null arrays as length 0. |
boolean |
isSameLength(double[] array1,
double[] array2)
Checks whether two arrays are the same length, treating
null arrays as length 0. |
boolean |
isSameLength(float[] array1,
float[] array2)
Checks whether two arrays are the same length, treating
null arrays as length 0. |
boolean |
isSameLength(int[] array1,
int[] array2)
Checks whether two arrays are the same length, treating
null arrays as length 0. |
boolean |
isSameLength(long[] array1,
long[] array2)
Checks whether two arrays are the same length, treating
null arrays as length 0. |
boolean |
isSameLength(Object[] array1,
Object[] array2)
Checks whether two arrays are the same length, treating
null arrays as length 0. |
boolean |
isSameLength(short[] array1,
short[] array2)
Checks whether two arrays are the same length, treating
null arrays as length 0. |
boolean |
isSameType(Object array1,
Object array2)
Checks whether two arrays are the same type taking into account
multi-dimensional arrays.
|
int |
lastIndexOf(boolean[] array,
boolean valueToFind)
Finds the last index of the given value within the array.
|
int |
lastIndexOf(boolean[] array,
boolean valueToFind,
int startIndex)
Finds the last index of the given value in the array starting at the given index.
|
int |
lastIndexOf(byte[] array,
byte valueToFind)
Finds the last index of the given value within the array.
|
int |
lastIndexOf(byte[] array,
byte valueToFind,
int startIndex)
Finds the last index of the given value in the array starting at the given index.
|
int |
lastIndexOf(char[] array,
char valueToFind)
Finds the last index of the given value within the array.
|
int |
lastIndexOf(char[] array,
char valueToFind,
int startIndex)
Finds the last index of the given value in the array starting at the given index.
|
int |
lastIndexOf(double[] array,
double valueToFind)
Finds the last index of the given value within the array.
|
int |
lastIndexOf(double[] array,
double valueToFind,
double tolerance)
Finds the last index of the given value within a given tolerance in the array.
|
int |
lastIndexOf(double[] array,
double valueToFind,
int startIndex)
Finds the last index of the given value in the array starting at the given index.
|
int |
lastIndexOf(double[] array,
double valueToFind,
int startIndex,
double tolerance)
Finds the last index of the given value in the array starting at the given index.
|
int |
lastIndexOf(float[] array,
float valueToFind)
Finds the last index of the given value within the array.
|
int |
lastIndexOf(float[] array,
float valueToFind,
int startIndex)
Finds the last index of the given value in the array starting at the given index.
|
int |
lastIndexOf(int[] array,
int valueToFind)
Finds the last index of the given value within the array.
|
int |
lastIndexOf(int[] array,
int valueToFind,
int startIndex)
Finds the last index of the given value in the array starting at the given index.
|
int |
lastIndexOf(long[] array,
long valueToFind)
Finds the last index of the given value within the array.
|
int |
lastIndexOf(long[] array,
long valueToFind,
int startIndex)
Finds the last index of the given value in the array starting at the given index.
|
int |
lastIndexOf(Object[] array,
Object objectToFind)
Finds the last index of the given object within the array.
|
int |
lastIndexOf(Object[] array,
Object objectToFind,
int startIndex)
Finds the last index of the given object in the array starting at the given index.
|
int |
lastIndexOf(short[] array,
short valueToFind)
Finds the last index of the given value within the array.
|
int |
lastIndexOf(short[] array,
short valueToFind,
int startIndex)
Finds the last index of the given value in the array starting at the given index.
|
<T> T[] |
newArray(Class<?> componentType,
int newSize)
新建一个空数组
|
boolean[] |
nullToEmpty(boolean[] array)
Defensive programming technique to change a
null
reference to an empty one. |
Boolean[] |
nullToEmpty(Boolean[] array)
Defensive programming technique to change a
null
reference to an empty one. |
byte[] |
nullToEmpty(byte[] array)
Defensive programming technique to change a
null
reference to an empty one. |
Byte[] |
nullToEmpty(Byte[] array)
Defensive programming technique to change a
null
reference to an empty one. |
char[] |
nullToEmpty(char[] array)
Defensive programming technique to change a
null
reference to an empty one. |
Character[] |
nullToEmpty(Character[] array)
Defensive programming technique to change a
null
reference to an empty one. |
double[] |
nullToEmpty(double[] array)
Defensive programming technique to change a
null
reference to an empty one. |
Double[] |
nullToEmpty(Double[] array)
Defensive programming technique to change a
null
reference to an empty one. |
float[] |
nullToEmpty(float[] array)
Defensive programming technique to change a
null
reference to an empty one. |
Float[] |
nullToEmpty(Float[] array)
Defensive programming technique to change a
null
reference to an empty one. |
int[] |
nullToEmpty(int[] array)
Defensive programming technique to change a
null
reference to an empty one. |
Integer[] |
nullToEmpty(Integer[] array)
Defensive programming technique to change a
null
reference to an empty one. |
long[] |
nullToEmpty(long[] array)
Defensive programming technique to change a
null
reference to an empty one. |
Long[] |
nullToEmpty(Long[] array)
Defensive programming technique to change a
null
reference to an empty one. |
Object[] |
nullToEmpty(Object[] array)
Defensive programming technique to change a
null
reference to an empty one. |
short[] |
nullToEmpty(short[] array)
Defensive programming technique to change a
null
reference to an empty one. |
Short[] |
nullToEmpty(Short[] array)
Defensive programming technique to change a
null
reference to an empty one. |
String[] |
nullToEmpty(String[] array)
Defensive programming technique to change a
null
reference to an empty one. |
boolean[] |
remove(boolean[] array,
int index)
Removes the element at the specified position from the specified array.
|
byte[] |
remove(byte[] array,
int index)
Removes the element at the specified position from the specified array.
|
char[] |
remove(char[] array,
int index)
Removes the element at the specified position from the specified array.
|
double[] |
remove(double[] array,
int index)
Removes the element at the specified position from the specified array.
|
float[] |
remove(float[] array,
int index)
Removes the element at the specified position from the specified array.
|
int[] |
remove(int[] array,
int index)
Removes the element at the specified position from the specified array.
|
long[] |
remove(long[] array,
int index)
Removes the element at the specified position from the specified array.
|
Object[] |
remove(Object[] array,
int index)
Removes the element at the specified position from the specified array.
|
short[] |
remove(short[] array,
int index)
Removes the element at the specified position from the specified array.
|
boolean[] |
removeElement(boolean[] array,
boolean element)
Removes the first occurrence of the specified element from the
specified array.
|
byte[] |
removeElement(byte[] array,
byte element)
Removes the first occurrence of the specified element from the
specified array.
|
char[] |
removeElement(char[] array,
char element)
Removes the first occurrence of the specified element from the
specified array.
|
double[] |
removeElement(double[] array,
double element)
Removes the first occurrence of the specified element from the
specified array.
|
float[] |
removeElement(float[] array,
float element)
Removes the first occurrence of the specified element from the
specified array.
|
int[] |
removeElement(int[] array,
int element)
Removes the first occurrence of the specified element from the
specified array.
|
long[] |
removeElement(long[] array,
long element)
Removes the first occurrence of the specified element from the
specified array.
|
Object[] |
removeElement(Object[] array,
Object element)
Removes the first occurrence of the specified element from the
specified array.
|
short[] |
removeElement(short[] array,
short element)
Removes the first occurrence of the specified element from the
specified array.
|
void |
reverse(boolean[] array)
Reverses the order of the given array.
|
void |
reverse(byte[] array)
Reverses the order of the given array.
|
void |
reverse(char[] array)
Reverses the order of the given array.
|
void |
reverse(double[] array)
Reverses the order of the given array.
|
void |
reverse(float[] array)
Reverses the order of the given array.
|
void |
reverse(int[] array)
Reverses the order of the given array.
|
void |
reverse(long[] array)
Reverses the order of the given array.
|
void |
reverse(Object[] array)
Reverses the order of the given array.
|
void |
reverse(short[] array)
Reverses the order of the given array.
|
boolean[] |
subarray(boolean[] array,
int startIndexInclusive,
int endIndexExclusive)
Produces a new
boolean array containing the elements
between the start and end indices. |
byte[] |
subarray(byte[] array,
int startIndexInclusive,
int endIndexExclusive)
Produces a new
byte array containing the elements
between the start and end indices. |
char[] |
subarray(char[] array,
int startIndexInclusive,
int endIndexExclusive)
Produces a new
char array containing the elements
between the start and end indices. |
double[] |
subarray(double[] array,
int startIndexInclusive,
int endIndexExclusive)
Produces a new
double array containing the elements
between the start and end indices. |
float[] |
subarray(float[] array,
int startIndexInclusive,
int endIndexExclusive)
Produces a new
float array containing the elements
between the start and end indices. |
int[] |
subarray(int[] array,
int startIndexInclusive,
int endIndexExclusive)
Produces a new
int array containing the elements
between the start and end indices. |
long[] |
subarray(long[] array,
int startIndexInclusive,
int endIndexExclusive)
Produces a new
long array containing the elements
between the start and end indices. |
Object[] |
subarray(Object[] array,
int startIndexInclusive,
int endIndexExclusive)
Produces a new array containing the elements between
the start and end indices.
|
short[] |
subarray(short[] array,
int startIndexInclusive,
int endIndexExclusive)
Produces a new
short array containing the elements
between the start and end indices. |
Map |
toMap(Object[] array)
Converts the given array into a
Map. |
Boolean[] |
toObject(boolean[] array)
Converts an array of primitive booleans to objects.
|
Byte[] |
toObject(byte[] array)
Converts an array of primitive bytes to objects.
|
Character[] |
toObject(char[] array)
Converts an array of primitive chars to objects.
|
Double[] |
toObject(double[] array)
Converts an array of primitive doubles to objects.
|
Float[] |
toObject(float[] array)
Converts an array of primitive floats to objects.
|
Integer[] |
toObject(int[] array)
Converts an array of primitive ints to objects.
|
Long[] |
toObject(long[] array)
Converts an array of primitive longs to objects.
|
Short[] |
toObject(short[] array)
Converts an array of primitive shorts to objects.
|
boolean[] |
toPrimitive(Boolean[] array)
Converts an array of object Booleans to primitives.
|
boolean[] |
toPrimitive(Boolean[] array,
boolean valueForNull)
Converts an array of object Booleans to primitives handling
null. |
byte[] |
toPrimitive(Byte[] array)
Converts an array of object Bytes to primitives.
|
byte[] |
toPrimitive(Byte[] array,
byte valueForNull)
Converts an array of object Bytes to primitives handling
null. |
char[] |
toPrimitive(Character[] array)
Converts an array of object Characters to primitives.
|
char[] |
toPrimitive(Character[] array,
char valueForNull)
Converts an array of object Character to primitives handling
null. |
double[] |
toPrimitive(Double[] array)
Converts an array of object Doubles to primitives.
|
double[] |
toPrimitive(Double[] array,
double valueForNull)
Converts an array of object Doubles to primitives handling
null. |
float[] |
toPrimitive(Float[] array)
Converts an array of object Floats to primitives.
|
float[] |
toPrimitive(Float[] array,
float valueForNull)
Converts an array of object Floats to primitives handling
null. |
int[] |
toPrimitive(Integer[] array)
Converts an array of object Integers to primitives.
|
int[] |
toPrimitive(Integer[] array,
int valueForNull)
Converts an array of object Integer to primitives handling
null. |
long[] |
toPrimitive(Long[] array)
Converts an array of object Longs to primitives.
|
long[] |
toPrimitive(Long[] array,
long valueForNull)
Converts an array of object Long to primitives handling
null. |
short[] |
toPrimitive(Short[] array)
Converts an array of object Shorts to primitives.
|
short[] |
toPrimitive(Short[] array,
short valueForNull)
Converts an array of object Short to primitives handling
null. |
String |
toString(Object obj)
数组或集合转String
|
public boolean isArray(Object obj)
obj - 对象NullPointerException - 提供被监测的对象为nullpublic Map toMap(Object[] array)
Converts the given array into a Map. Each element of the array
must be either a Map.Entry or an Array, containing at least two
elements, where the first element is used as key and the second as
value.
This method can be used to initialize:
// Create a Map mapping colors.
Map colorMap = MapUtils.toMap(new String[][] {{
{"RED", "#FF0000"},
{"GREEN", "#00FF00"},
{"BLUE", "#0000FF"}});
This method returns null for a null input array.
array - an array whose elements are either a Map.Entry or
an Array containing at least two elements, may be nullMap that was created from the arrayIllegalArgumentException - if one element of this Array is
itself an Array containing less then two elementsIllegalArgumentException - if the array contains elements other
than Map.Entry and an Arraypublic Object[] clone(Object[] array)
Shallow clones an array returning a typecast result and handling
null.
The objects in the array are not cloned, thus there is no special handling for multi-dimensional arrays.
This method returns null for a null input array.
array - the array to shallow clone, may be nullnull if null inputpublic long[] clone(long[] array)
Clones an array returning a typecast result and handling
null.
This method returns null for a null input array.
array - the array to clone, may be nullnull if null inputpublic int[] clone(int[] array)
Clones an array returning a typecast result and handling
null.
This method returns null for a null input array.
array - the array to clone, may be nullnull if null inputpublic short[] clone(short[] array)
Clones an array returning a typecast result and handling
null.
This method returns null for a null input array.
array - the array to clone, may be nullnull if null inputpublic char[] clone(char[] array)
Clones an array returning a typecast result and handling
null.
This method returns null for a null input array.
array - the array to clone, may be nullnull if null inputpublic byte[] clone(byte[] array)
Clones an array returning a typecast result and handling
null.
This method returns null for a null input array.
array - the array to clone, may be nullnull if null inputpublic double[] clone(double[] array)
Clones an array returning a typecast result and handling
null.
This method returns null for a null input array.
array - the array to clone, may be nullnull if null inputpublic float[] clone(float[] array)
Clones an array returning a typecast result and handling
null.
This method returns null for a null input array.
array - the array to clone, may be nullnull if null inputpublic boolean[] clone(boolean[] array)
Clones an array returning a typecast result and handling
null.
This method returns null for a null input array.
array - the array to clone, may be nullnull if null inputpublic Object[] nullToEmpty(Object[] array)
Defensive programming technique to change a null
reference to an empty one.
This method returns an empty array for a null input array.
As a memory optimizing technique an empty array passed in will be overridden with
the empty public references in this class.
array - the array to check for null or emptypublic empty array if null or empty inputpublic String[] nullToEmpty(String[] array)
Defensive programming technique to change a null
reference to an empty one.
This method returns an empty array for a null input array.
As a memory optimizing technique an empty array passed in will be overridden with
the empty public references in this class.
array - the array to check for null or emptypublic empty array if null or empty inputpublic long[] nullToEmpty(long[] array)
Defensive programming technique to change a null
reference to an empty one.
This method returns an empty array for a null input array.
As a memory optimizing technique an empty array passed in will be overridden with
the empty public references in this class.
array - the array to check for null or emptypublic empty array if null or empty inputpublic int[] nullToEmpty(int[] array)
Defensive programming technique to change a null
reference to an empty one.
This method returns an empty array for a null input array.
As a memory optimizing technique an empty array passed in will be overridden with
the empty public references in this class.
array - the array to check for null or emptypublic empty array if null or empty inputpublic short[] nullToEmpty(short[] array)
Defensive programming technique to change a null
reference to an empty one.
This method returns an empty array for a null input array.
As a memory optimizing technique an empty array passed in will be overridden with
the empty public references in this class.
array - the array to check for null or emptypublic empty array if null or empty inputpublic char[] nullToEmpty(char[] array)
Defensive programming technique to change a null
reference to an empty one.
This method returns an empty array for a null input array.
As a memory optimizing technique an empty array passed in will be overridden with
the empty public references in this class.
array - the array to check for null or emptypublic empty array if null or empty inputpublic byte[] nullToEmpty(byte[] array)
Defensive programming technique to change a null
reference to an empty one.
This method returns an empty array for a null input array.
As a memory optimizing technique an empty array passed in will be overridden with
the empty public references in this class.
array - the array to check for null or emptypublic empty array if null or empty inputpublic double[] nullToEmpty(double[] array)
Defensive programming technique to change a null
reference to an empty one.
This method returns an empty array for a null input array.
As a memory optimizing technique an empty array passed in will be overridden with
the empty public references in this class.
array - the array to check for null or emptypublic empty array if null or empty inputpublic float[] nullToEmpty(float[] array)
Defensive programming technique to change a null
reference to an empty one.
This method returns an empty array for a null input array.
As a memory optimizing technique an empty array passed in will be overridden with
the empty public references in this class.
array - the array to check for null or emptypublic empty array if null or empty inputpublic boolean[] nullToEmpty(boolean[] array)
Defensive programming technique to change a null
reference to an empty one.
This method returns an empty array for a null input array.
As a memory optimizing technique an empty array passed in will be overridden with
the empty public references in this class.
array - the array to check for null or emptypublic empty array if null or empty inputpublic Long[] nullToEmpty(Long[] array)
Defensive programming technique to change a null
reference to an empty one.
This method returns an empty array for a null input array.
As a memory optimizing technique an empty array passed in will be overridden with
the empty public references in this class.
array - the array to check for null or emptypublic empty array if null or empty inputpublic Integer[] nullToEmpty(Integer[] array)
Defensive programming technique to change a null
reference to an empty one.
This method returns an empty array for a null input array.
As a memory optimizing technique an empty array passed in will be overridden with
the empty public references in this class.
array - the array to check for null or emptypublic empty array if null or empty inputpublic Short[] nullToEmpty(Short[] array)
Defensive programming technique to change a null
reference to an empty one.
This method returns an empty array for a null input array.
As a memory optimizing technique an empty array passed in will be overridden with
the empty public references in this class.
array - the array to check for null or emptypublic empty array if null or empty inputpublic Character[] nullToEmpty(Character[] array)
Defensive programming technique to change a null
reference to an empty one.
This method returns an empty array for a null input array.
As a memory optimizing technique an empty array passed in will be overridden with
the empty public references in this class.
array - the array to check for null or emptypublic empty array if null or empty inputpublic Byte[] nullToEmpty(Byte[] array)
Defensive programming technique to change a null
reference to an empty one.
This method returns an empty array for a null input array.
As a memory optimizing technique an empty array passed in will be overridden with
the empty public references in this class.
array - the array to check for null or emptypublic empty array if null or empty inputpublic Double[] nullToEmpty(Double[] array)
Defensive programming technique to change a null
reference to an empty one.
This method returns an empty array for a null input array.
As a memory optimizing technique an empty array passed in will be overridden with
the empty public references in this class.
array - the array to check for null or emptypublic empty array if null or empty inputpublic Float[] nullToEmpty(Float[] array)
Defensive programming technique to change a null
reference to an empty one.
This method returns an empty array for a null input array.
As a memory optimizing technique an empty array passed in will be overridden with
the empty public references in this class.
array - the array to check for null or emptypublic empty array if null or empty inputpublic Boolean[] nullToEmpty(Boolean[] array)
Defensive programming technique to change a null
reference to an empty one.
This method returns an empty array for a null input array.
As a memory optimizing technique an empty array passed in will be overridden with
the empty public references in this class.
array - the array to check for null or emptypublic empty array if null or empty inputpublic Object[] subarray(Object[] array, int startIndexInclusive, int endIndexExclusive)
Produces a new array containing the elements between the start and end indices.
The start index is inclusive, the end index exclusive. Null array input produces null output.
The component type of the subarray is always the same as
that of the input array. Thus, if the input is an array of type
Date, the following usage is envisaged:
Date[] someDates = (Date[])ArrayUtils.subarray(allDates, 2, 5);
array - the arraystartIndexInclusive - the starting index. Undervalue (<0)
is promoted to 0, overvalue (>array.length) results
in an empty array.endIndexExclusive - elements up to endIndex-1 are present in the
returned subarray. Undervalue (< startIndex) produces
empty array, overvalue (>array.length) is demoted to
array length.public long[] subarray(long[] array,
int startIndexInclusive,
int endIndexExclusive)
Produces a new long array containing the elements
between the start and end indices.
The start index is inclusive, the end index exclusive. Null array input produces null output.
array - the arraystartIndexInclusive - the starting index. Undervalue (<0)
is promoted to 0, overvalue (>array.length) results
in an empty array.endIndexExclusive - elements up to endIndex-1 are present in the
returned subarray. Undervalue (< startIndex) produces
empty array, overvalue (>array.length) is demoted to
array length.public int[] subarray(int[] array,
int startIndexInclusive,
int endIndexExclusive)
Produces a new int array containing the elements
between the start and end indices.
The start index is inclusive, the end index exclusive. Null array input produces null output.
array - the arraystartIndexInclusive - the starting index. Undervalue (<0)
is promoted to 0, overvalue (>array.length) results
in an empty array.endIndexExclusive - elements up to endIndex-1 are present in the
returned subarray. Undervalue (< startIndex) produces
empty array, overvalue (>array.length) is demoted to
array length.public short[] subarray(short[] array,
int startIndexInclusive,
int endIndexExclusive)
Produces a new short array containing the elements
between the start and end indices.
The start index is inclusive, the end index exclusive. Null array input produces null output.
array - the arraystartIndexInclusive - the starting index. Undervalue (<0)
is promoted to 0, overvalue (>array.length) results
in an empty array.endIndexExclusive - elements up to endIndex-1 are present in the
returned subarray. Undervalue (< startIndex) produces
empty array, overvalue (>array.length) is demoted to
array length.public char[] subarray(char[] array,
int startIndexInclusive,
int endIndexExclusive)
Produces a new char array containing the elements
between the start and end indices.
The start index is inclusive, the end index exclusive. Null array input produces null output.
array - the arraystartIndexInclusive - the starting index. Undervalue (<0)
is promoted to 0, overvalue (>array.length) results
in an empty array.endIndexExclusive - elements up to endIndex-1 are present in the
returned subarray. Undervalue (< startIndex) produces
empty array, overvalue (>array.length) is demoted to
array length.public byte[] subarray(byte[] array,
int startIndexInclusive,
int endIndexExclusive)
Produces a new byte array containing the elements
between the start and end indices.
The start index is inclusive, the end index exclusive. Null array input produces null output.
array - the arraystartIndexInclusive - the starting index. Undervalue (<0)
is promoted to 0, overvalue (>array.length) results
in an empty array.endIndexExclusive - elements up to endIndex-1 are present in the
returned subarray. Undervalue (< startIndex) produces
empty array, overvalue (>array.length) is demoted to
array length.public double[] subarray(double[] array,
int startIndexInclusive,
int endIndexExclusive)
Produces a new double array containing the elements
between the start and end indices.
The start index is inclusive, the end index exclusive. Null array input produces null output.
array - the arraystartIndexInclusive - the starting index. Undervalue (<0)
is promoted to 0, overvalue (>array.length) results
in an empty array.endIndexExclusive - elements up to endIndex-1 are present in the
returned subarray. Undervalue (< startIndex) produces
empty array, overvalue (>array.length) is demoted to
array length.public float[] subarray(float[] array,
int startIndexInclusive,
int endIndexExclusive)
Produces a new float array containing the elements
between the start and end indices.
The start index is inclusive, the end index exclusive. Null array input produces null output.
array - the arraystartIndexInclusive - the starting index. Undervalue (<0)
is promoted to 0, overvalue (>array.length) results
in an empty array.endIndexExclusive - elements up to endIndex-1 are present in the
returned subarray. Undervalue (< startIndex) produces
empty array, overvalue (>array.length) is demoted to
array length.public boolean[] subarray(boolean[] array,
int startIndexInclusive,
int endIndexExclusive)
Produces a new boolean array containing the elements
between the start and end indices.
The start index is inclusive, the end index exclusive. Null array input produces null output.
array - the arraystartIndexInclusive - the starting index. Undervalue (<0)
is promoted to 0, overvalue (>array.length) results
in an empty array.endIndexExclusive - elements up to endIndex-1 are present in the
returned subarray. Undervalue (< startIndex) produces
empty array, overvalue (>array.length) is demoted to
array length.public boolean isSameLength(Object[] array1, Object[] array2)
Checks whether two arrays are the same length, treating
null arrays as length 0.
Any multi-dimensional aspects of the arrays are ignored.
array1 - the first array, may be nullarray2 - the second array, may be nulltrue if length of arrays matches, treating
null as an empty arraypublic boolean isSameLength(long[] array1,
long[] array2)
Checks whether two arrays are the same length, treating
null arrays as length 0.
array1 - the first array, may be nullarray2 - the second array, may be nulltrue if length of arrays matches, treating
null as an empty arraypublic boolean isSameLength(int[] array1,
int[] array2)
Checks whether two arrays are the same length, treating
null arrays as length 0.
array1 - the first array, may be nullarray2 - the second array, may be nulltrue if length of arrays matches, treating
null as an empty arraypublic boolean isSameLength(short[] array1,
short[] array2)
Checks whether two arrays are the same length, treating
null arrays as length 0.
array1 - the first array, may be nullarray2 - the second array, may be nulltrue if length of arrays matches, treating
null as an empty arraypublic boolean isSameLength(char[] array1,
char[] array2)
Checks whether two arrays are the same length, treating
null arrays as length 0.
array1 - the first array, may be nullarray2 - the second array, may be nulltrue if length of arrays matches, treating
null as an empty arraypublic boolean isSameLength(byte[] array1,
byte[] array2)
Checks whether two arrays are the same length, treating
null arrays as length 0.
array1 - the first array, may be nullarray2 - the second array, may be nulltrue if length of arrays matches, treating
null as an empty arraypublic boolean isSameLength(double[] array1,
double[] array2)
Checks whether two arrays are the same length, treating
null arrays as length 0.
array1 - the first array, may be nullarray2 - the second array, may be nulltrue if length of arrays matches, treating
null as an empty arraypublic boolean isSameLength(float[] array1,
float[] array2)
Checks whether two arrays are the same length, treating
null arrays as length 0.
array1 - the first array, may be nullarray2 - the second array, may be nulltrue if length of arrays matches, treating
null as an empty arraypublic boolean isSameLength(boolean[] array1,
boolean[] array2)
Checks whether two arrays are the same length, treating
null arrays as length 0.
array1 - the first array, may be nullarray2 - the second array, may be nulltrue if length of arrays matches, treating
null as an empty arraypublic int getLength(Object array)
Returns the length of the specified array.
This method can deal with Object arrays and with primitive arrays.
If the input array is null, 0 is returned.
ArrayUtils.getLength(null) = 0 ArrayUtils.getLength([]) = 0 ArrayUtils.getLength([null]) = 1 ArrayUtils.getLength([true, false]) = 2 ArrayUtils.getLength([1, 2, 3]) = 3 ArrayUtils.getLength(["a", "b", "c"]) = 3
array - the array to retrieve the length from, may be null0 if the array is nullIllegalArgumentException - if the object arguement is not an array.public boolean isSameType(Object array1, Object array2)
Checks whether two arrays are the same type taking into account multi-dimensional arrays.
array1 - the first array, must not be nullarray2 - the second array, must not be nulltrue if type of arrays matchesIllegalArgumentException - if either array is nullpublic void reverse(Object[] array)
Reverses the order of the given array.
There is no special handling for multi-dimensional arrays.
This method does nothing for a null input array.
array - the array to reverse, may be nullpublic void reverse(long[] array)
Reverses the order of the given array.
This method does nothing for a null input array.
array - the array to reverse, may be nullpublic void reverse(int[] array)
Reverses the order of the given array.
This method does nothing for a null input array.
array - the array to reverse, may be nullpublic void reverse(short[] array)
Reverses the order of the given array.
This method does nothing for a null input array.
array - the array to reverse, may be nullpublic void reverse(char[] array)
Reverses the order of the given array.
This method does nothing for a null input array.
array - the array to reverse, may be nullpublic void reverse(byte[] array)
Reverses the order of the given array.
This method does nothing for a null input array.
array - the array to reverse, may be nullpublic void reverse(double[] array)
Reverses the order of the given array.
This method does nothing for a null input array.
array - the array to reverse, may be nullpublic void reverse(float[] array)
Reverses the order of the given array.
This method does nothing for a null input array.
array - the array to reverse, may be nullpublic void reverse(boolean[] array)
Reverses the order of the given array.
This method does nothing for a null input array.
array - the array to reverse, may be nullpublic int indexOf(Object[] array, Object objectToFind)
Finds the index of the given object in the array.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
array - the array to search through for the object, may be nullobjectToFind - the object to find, may be nullArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int indexOf(Object[] array, Object objectToFind, int startIndex)
Finds the index of the given object in the array starting at the given index.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex is treated as zero. A startIndex larger than the array
length will return ArrayConst.INDEX_NOT_FOUND (-1).
array - the array to search through for the object, may be nullobjectToFind - the object to find, may be nullstartIndex - the index to start searching atArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int lastIndexOf(Object[] array, Object objectToFind)
Finds the last index of the given object within the array.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
array - the array to travers backwords looking for the object, may be nullobjectToFind - the object to find, may be nullArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int lastIndexOf(Object[] array, Object objectToFind, int startIndex)
Finds the last index of the given object in the array starting at the given index.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex will return ArrayConst.INDEX_NOT_FOUND (-1). A startIndex larger than
the array length will search from the end of the array.
array - the array to traverse for looking for the object, may be nullobjectToFind - the object to find, may be nullstartIndex - the start index to travers backwards fromArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic boolean contains(Object[] array, Object objectToFind)
Checks if the object is in the given array.
The method returns false if a null array is passed in.
array - the array to search throughobjectToFind - the object to findtrue if the array contains the objectpublic int indexOf(long[] array,
long valueToFind)
Finds the index of the given value in the array.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
array - the array to search through for the object, may be nullvalueToFind - the value to findArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int indexOf(long[] array,
long valueToFind,
int startIndex)
Finds the index of the given value in the array starting at the given index.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex is treated as zero. A startIndex larger than the array
length will return ArrayConst.INDEX_NOT_FOUND (-1).
array - the array to search through for the object, may be nullvalueToFind - the value to findstartIndex - the index to start searching atArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int lastIndexOf(long[] array,
long valueToFind)
Finds the last index of the given value within the array.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
array - the array to travers backwords looking for the object, may be nullvalueToFind - the object to findArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int lastIndexOf(long[] array,
long valueToFind,
int startIndex)
Finds the last index of the given value in the array starting at the given index.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex will return ArrayConst.INDEX_NOT_FOUND (-1). A startIndex larger than the
array length will search from the end of the array.
array - the array to traverse for looking for the object, may be nullvalueToFind - the value to findstartIndex - the start index to travers backwards fromArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic boolean contains(long[] array,
long valueToFind)
Checks if the value is in the given array.
The method returns false if a null array is passed in.
array - the array to search throughvalueToFind - the value to findtrue if the array contains the objectpublic int indexOf(int[] array,
int valueToFind)
Finds the index of the given value in the array.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
array - the array to search through for the object, may be nullvalueToFind - the value to findArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int indexOf(int[] array,
int valueToFind,
int startIndex)
Finds the index of the given value in the array starting at the given index.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex is treated as zero. A startIndex larger than the array
length will return ArrayConst.INDEX_NOT_FOUND (-1).
array - the array to search through for the object, may be nullvalueToFind - the value to findstartIndex - the index to start searching atArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int lastIndexOf(int[] array,
int valueToFind)
Finds the last index of the given value within the array.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
array - the array to travers backwords looking for the object, may be nullvalueToFind - the object to findArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int lastIndexOf(int[] array,
int valueToFind,
int startIndex)
Finds the last index of the given value in the array starting at the given index.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex will return ArrayConst.INDEX_NOT_FOUND (-1). A startIndex larger than the
array length will search from the end of the array.
array - the array to traverse for looking for the object, may be nullvalueToFind - the value to findstartIndex - the start index to travers backwards fromArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic boolean contains(int[] array,
int valueToFind)
Checks if the value is in the given array.
The method returns false if a null array is passed in.
array - the array to search throughvalueToFind - the value to findtrue if the array contains the objectpublic int indexOf(short[] array,
short valueToFind)
Finds the index of the given value in the array.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
array - the array to search through for the object, may be nullvalueToFind - the value to findArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int indexOf(short[] array,
short valueToFind,
int startIndex)
Finds the index of the given value in the array starting at the given index.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex is treated as zero. A startIndex larger than the array
length will return ArrayConst.INDEX_NOT_FOUND (-1).
array - the array to search through for the object, may be nullvalueToFind - the value to findstartIndex - the index to start searching atArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int lastIndexOf(short[] array,
short valueToFind)
Finds the last index of the given value within the array.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
array - the array to travers backwords looking for the object, may be nullvalueToFind - the object to findArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int lastIndexOf(short[] array,
short valueToFind,
int startIndex)
Finds the last index of the given value in the array starting at the given index.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex will return ArrayConst.INDEX_NOT_FOUND (-1). A startIndex larger than the
array length will search from the end of the array.
array - the array to traverse for looking for the object, may be nullvalueToFind - the value to findstartIndex - the start index to travers backwards fromArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic boolean contains(short[] array,
short valueToFind)
Checks if the value is in the given array.
The method returns false if a null array is passed in.
array - the array to search throughvalueToFind - the value to findtrue if the array contains the objectpublic int indexOf(char[] array,
char valueToFind)
Finds the index of the given value in the array.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
array - the array to search through for the object, may be nullvalueToFind - the value to findArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int indexOf(char[] array,
char valueToFind,
int startIndex)
Finds the index of the given value in the array starting at the given index.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex is treated as zero. A startIndex larger than the array
length will return ArrayConst.INDEX_NOT_FOUND (-1).
array - the array to search through for the object, may be nullvalueToFind - the value to findstartIndex - the index to start searching atArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int lastIndexOf(char[] array,
char valueToFind)
Finds the last index of the given value within the array.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
array - the array to travers backwords looking for the object, may be nullvalueToFind - the object to findArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int lastIndexOf(char[] array,
char valueToFind,
int startIndex)
Finds the last index of the given value in the array starting at the given index.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex will return ArrayConst.INDEX_NOT_FOUND (-1). A startIndex larger than the
array length will search from the end of the array.
array - the array to traverse for looking for the object, may be nullvalueToFind - the value to findstartIndex - the start index to travers backwards fromArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic boolean contains(char[] array,
char valueToFind)
Checks if the value is in the given array.
The method returns false if a null array is passed in.
array - the array to search throughvalueToFind - the value to findtrue if the array contains the objectpublic int indexOf(byte[] array,
byte valueToFind)
Finds the index of the given value in the array.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
array - the array to search through for the object, may be nullvalueToFind - the value to findArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int indexOf(byte[] array,
byte valueToFind,
int startIndex)
Finds the index of the given value in the array starting at the given index.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex is treated as zero. A startIndex larger than the array
length will return ArrayConst.INDEX_NOT_FOUND (-1).
array - the array to search through for the object, may be nullvalueToFind - the value to findstartIndex - the index to start searching atArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int lastIndexOf(byte[] array,
byte valueToFind)
Finds the last index of the given value within the array.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
array - the array to travers backwords looking for the object, may be nullvalueToFind - the object to findArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int lastIndexOf(byte[] array,
byte valueToFind,
int startIndex)
Finds the last index of the given value in the array starting at the given index.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex will return ArrayConst.INDEX_NOT_FOUND (-1). A startIndex larger than the
array length will search from the end of the array.
array - the array to traverse for looking for the object, may be nullvalueToFind - the value to findstartIndex - the start index to travers backwards fromArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic boolean contains(byte[] array,
byte valueToFind)
Checks if the value is in the given array.
The method returns false if a null array is passed in.
array - the array to search throughvalueToFind - the value to findtrue if the array contains the objectpublic int indexOf(double[] array,
double valueToFind)
Finds the index of the given value in the array.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
array - the array to search through for the object, may be nullvalueToFind - the value to findArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int indexOf(double[] array,
double valueToFind,
double tolerance)
Finds the index of the given value within a given tolerance in the array. This method will return the index of the first value which falls between the region defined by valueToFind - tolerance and valueToFind + tolerance.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
array - the array to search through for the object, may be nullvalueToFind - the value to findtolerance - tolerance of the searchArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int indexOf(double[] array,
double valueToFind,
int startIndex)
Finds the index of the given value in the array starting at the given index.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex is treated as zero. A startIndex larger than the array
length will return ArrayConst.INDEX_NOT_FOUND (-1).
array - the array to search through for the object, may be nullvalueToFind - the value to findstartIndex - the index to start searching atArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int indexOf(double[] array,
double valueToFind,
int startIndex,
double tolerance)
Finds the index of the given value in the array starting at the given index. This method will return the index of the first value which falls between the region defined by valueToFind - tolerance and valueToFind + tolerance.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex is treated as zero. A startIndex larger than the array
length will return ArrayConst.INDEX_NOT_FOUND (-1).
array - the array to search through for the object, may be nullvalueToFind - the value to findstartIndex - the index to start searching attolerance - tolerance of the searchArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int lastIndexOf(double[] array,
double valueToFind)
Finds the last index of the given value within the array.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
array - the array to travers backwords looking for the object, may be nullvalueToFind - the object to findArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int lastIndexOf(double[] array,
double valueToFind,
double tolerance)
Finds the last index of the given value within a given tolerance in the array. This method will return the index of the last value which falls between the region defined by valueToFind - tolerance and valueToFind + tolerance.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
array - the array to search through for the object, may be nullvalueToFind - the value to findtolerance - tolerance of the searchArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int lastIndexOf(double[] array,
double valueToFind,
int startIndex)
Finds the last index of the given value in the array starting at the given index.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex will return ArrayConst.INDEX_NOT_FOUND (-1). A startIndex larger than the
array length will search from the end of the array.
array - the array to traverse for looking for the object, may be nullvalueToFind - the value to findstartIndex - the start index to travers backwards fromArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int lastIndexOf(double[] array,
double valueToFind,
int startIndex,
double tolerance)
Finds the last index of the given value in the array starting at the given index. This method will return the index of the last value which falls between the region defined by valueToFind - tolerance and valueToFind + tolerance.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex will return ArrayConst.INDEX_NOT_FOUND (-1). A startIndex larger than the
array length will search from the end of the array.
array - the array to traverse for looking for the object, may be nullvalueToFind - the value to findstartIndex - the start index to travers backwards fromtolerance - search for value within plus/minus this amountArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic boolean contains(double[] array,
double valueToFind)
Checks if the value is in the given array.
The method returns false if a null array is passed in.
array - the array to search throughvalueToFind - the value to findtrue if the array contains the objectpublic boolean contains(double[] array,
double valueToFind,
double tolerance)
Checks if a value falling within the given tolerance is in the given array. If the array contains a value within the inclusive range defined by (value - tolerance) to (value + tolerance).
The method returns false if a null array
is passed in.
array - the array to searchvalueToFind - the value to findtolerance - the array contains the tolerance of the searchpublic int indexOf(float[] array,
float valueToFind)
Finds the index of the given value in the array.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
array - the array to search through for the object, may be nullvalueToFind - the value to findArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int indexOf(float[] array,
float valueToFind,
int startIndex)
Finds the index of the given value in the array starting at the given index.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex is treated as zero. A startIndex larger than the array
length will return ArrayConst.INDEX_NOT_FOUND (-1).
array - the array to search through for the object, may be nullvalueToFind - the value to findstartIndex - the index to start searching atArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int lastIndexOf(float[] array,
float valueToFind)
Finds the last index of the given value within the array.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
array - the array to travers backwords looking for the object, may be nullvalueToFind - the object to findArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int lastIndexOf(float[] array,
float valueToFind,
int startIndex)
Finds the last index of the given value in the array starting at the given index.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex will return ArrayConst.INDEX_NOT_FOUND (-1). A startIndex larger than the
array length will search from the end of the array.
array - the array to traverse for looking for the object, may be nullvalueToFind - the value to findstartIndex - the start index to travers backwards fromArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic boolean contains(float[] array,
float valueToFind)
Checks if the value is in the given array.
The method returns false if a null array is passed in.
array - the array to search throughvalueToFind - the value to findtrue if the array contains the objectpublic int indexOf(boolean[] array,
boolean valueToFind)
Finds the index of the given value in the array.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
array - the array to search through for the object, may be nullvalueToFind - the value to findArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int indexOf(boolean[] array,
boolean valueToFind,
int startIndex)
Finds the index of the given value in the array starting at the given index.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex is treated as zero. A startIndex larger than the array
length will return ArrayConst.INDEX_NOT_FOUND (-1).
array - the array to search through for the object, may be nullvalueToFind - the value to findstartIndex - the index to start searching atArrayConst.INDEX_NOT_FOUND (-1) if not found or null
array inputpublic int lastIndexOf(boolean[] array,
boolean valueToFind)
Finds the last index of the given value within the array.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) if
null array input.
array - the array to travers backwords looking for the object, may be nullvalueToFind - the object to findArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic int lastIndexOf(boolean[] array,
boolean valueToFind,
int startIndex)
Finds the last index of the given value in the array starting at the given index.
This method returns ArrayConst.INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex will return ArrayConst.INDEX_NOT_FOUND (-1). A startIndex larger than
the array length will search from the end of the array.
array - the array to traverse for looking for the object, may be nullvalueToFind - the value to findstartIndex - the start index to travers backwards fromArrayConst.INDEX_NOT_FOUND (-1) if not found or null array inputpublic boolean contains(boolean[] array,
boolean valueToFind)
Checks if the value is in the given array.
The method returns false if a null array is passed in.
array - the array to search throughvalueToFind - the value to findtrue if the array contains the objectpublic char[] toPrimitive(Character[] array)
Converts an array of object Characters to primitives.
This method returns null for a null input array.
array - a Character array, may be nullchar array, null if null array inputNullPointerException - if array content is nullpublic char[] toPrimitive(Character[] array, char valueForNull)
Converts an array of object Character to primitives handling null.
This method returns null for a null input array.
array - a Character array, may be nullvalueForNull - the value to insert if null foundchar array, null if null array inputpublic Character[] toObject(char[] array)
Converts an array of primitive chars to objects.
This method returns null for a null input array.
array - a char arrayCharacter array, null if null array inputpublic long[] toPrimitive(Long[] array)
Converts an array of object Longs to primitives.
This method returns null for a null input array.
array - a Long array, may be nulllong array, null if null array inputNullPointerException - if array content is nullpublic long[] toPrimitive(Long[] array, long valueForNull)
Converts an array of object Long to primitives handling null.
This method returns null for a null input array.
array - a Long array, may be nullvalueForNull - the value to insert if null foundlong array, null if null array inputpublic Long[] toObject(long[] array)
Converts an array of primitive longs to objects.
This method returns null for a null input array.
array - a long arrayLong array, null if null array inputpublic int[] toPrimitive(Integer[] array)
Converts an array of object Integers to primitives.
This method returns null for a null input array.
array - a Integer array, may be nullint array, null if null array inputNullPointerException - if array content is nullpublic int[] toPrimitive(Integer[] array, int valueForNull)
Converts an array of object Integer to primitives handling null.
This method returns null for a null input array.
array - a Integer array, may be nullvalueForNull - the value to insert if null foundint array, null if null array inputpublic Integer[] toObject(int[] array)
Converts an array of primitive ints to objects.
This method returns null for a null input array.
array - an int arrayInteger array, null if null array inputpublic short[] toPrimitive(Short[] array)
Converts an array of object Shorts to primitives.
This method returns null for a null input array.
array - a Short array, may be nullbyte array, null if null array inputNullPointerException - if array content is nullpublic short[] toPrimitive(Short[] array, short valueForNull)
Converts an array of object Short to primitives handling null.
This method returns null for a null input array.
array - a Short array, may be nullvalueForNull - the value to insert if null foundbyte array, null if null array inputpublic Short[] toObject(short[] array)
Converts an array of primitive shorts to objects.
This method returns null for a null input array.
array - a short arrayShort array, null if null array inputpublic byte[] toPrimitive(Byte[] array)
Converts an array of object Bytes to primitives.
This method returns null for a null input array.
array - a Byte array, may be nullbyte array, null if null array inputNullPointerException - if array content is nullpublic byte[] toPrimitive(Byte[] array, byte valueForNull)
Converts an array of object Bytes to primitives handling null.
This method returns null for a null input array.
array - a Byte array, may be nullvalueForNull - the value to insert if null foundbyte array, null if null array inputpublic Byte[] toObject(byte[] array)
Converts an array of primitive bytes to objects.
This method returns null for a null input array.
array - a byte arrayByte array, null if null array inputpublic double[] toPrimitive(Double[] array)
Converts an array of object Doubles to primitives.
This method returns null for a null input array.
array - a Double array, may be nulldouble array, null if null array inputNullPointerException - if array content is nullpublic double[] toPrimitive(Double[] array, double valueForNull)
Converts an array of object Doubles to primitives handling null.
This method returns null for a null input array.
array - a Double array, may be nullvalueForNull - the value to insert if null founddouble array, null if null array inputpublic Double[] toObject(double[] array)
Converts an array of primitive doubles to objects.
This method returns null for a null input array.
array - a double arrayDouble array, null if null array inputpublic float[] toPrimitive(Float[] array)
Converts an array of object Floats to primitives.
This method returns null for a null input array.
array - a Float array, may be nullfloat array, null if null array inputNullPointerException - if array content is nullpublic float[] toPrimitive(Float[] array, float valueForNull)
Converts an array of object Floats to primitives handling null.
This method returns null for a null input array.
array - a Float array, may be nullvalueForNull - the value to insert if null foundfloat array, null if null array inputpublic Float[] toObject(float[] array)
Converts an array of primitive floats to objects.
This method returns null for a null input array.
array - a float arrayFloat array, null if null array inputpublic boolean[] toPrimitive(Boolean[] array)
Converts an array of object Booleans to primitives.
This method returns null for a null input array.
array - a Boolean array, may be nullboolean array, null if null array inputNullPointerException - if array content is nullpublic boolean[] toPrimitive(Boolean[] array, boolean valueForNull)
Converts an array of object Booleans to primitives handling null.
This method returns null for a null input array.
array - a Boolean array, may be nullvalueForNull - the value to insert if null foundboolean array, null if null array inputpublic Boolean[] toObject(boolean[] array)
Converts an array of primitive booleans to objects.
This method returns null for a null input array.
array - a boolean arrayBoolean array, null if null array inputpublic boolean isEmpty(Object[] array)
Checks if an array of Objects is empty or null.
array - the array to testtrue if the array is empty or nullpublic boolean isEmpty(long[] array)
Checks if an array of primitive longs is empty or null.
array - the array to testtrue if the array is empty or nullpublic boolean isEmpty(int[] array)
Checks if an array of primitive ints is empty or null.
array - the array to testtrue if the array is empty or nullpublic boolean isEmpty(short[] array)
Checks if an array of primitive shorts is empty or null.
array - the array to testtrue if the array is empty or nullpublic boolean isEmpty(char[] array)
Checks if an array of primitive chars is empty or null.
array - the array to testtrue if the array is empty or nullpublic boolean isEmpty(byte[] array)
Checks if an array of primitive bytes is empty or null.
array - the array to testtrue if the array is empty or nullpublic boolean isEmpty(double[] array)
Checks if an array of primitive doubles is empty or null.
array - the array to testtrue if the array is empty or nullpublic boolean isEmpty(float[] array)
Checks if an array of primitive floats is empty or null.
array - the array to testtrue if the array is empty or nullpublic boolean isEmpty(boolean[] array)
Checks if an array of primitive booleans is empty or null.
array - the array to testtrue if the array is empty or nullpublic boolean isNotEmpty(Object[] array)
Checks if an array of Objects is not empty or not null.
array - the array to testtrue if the array is not empty or not nullpublic boolean isNotEmpty(long[] array)
Checks if an array of primitive longs is not empty or not null.
array - the array to testtrue if the array is not empty or not nullpublic boolean isNotEmpty(int[] array)
Checks if an array of primitive ints is not empty or not null.
array - the array to testtrue if the array is not empty or not nullpublic boolean isNotEmpty(short[] array)
Checks if an array of primitive shorts is not empty or not null.
array - the array to testtrue if the array is not empty or not nullpublic boolean isNotEmpty(char[] array)
Checks if an array of primitive chars is not empty or not null.
array - the array to testtrue if the array is not empty or not nullpublic boolean isNotEmpty(byte[] array)
Checks if an array of primitive bytes is not empty or not null.
array - the array to testtrue if the array is not empty or not nullpublic boolean isNotEmpty(double[] array)
Checks if an array of primitive doubles is not empty or not null.
array - the array to testtrue if the array is not empty or not nullpublic boolean isNotEmpty(float[] array)
Checks if an array of primitive floats is not empty or not null.
array - the array to testtrue if the array is not empty or not nullpublic boolean isNotEmpty(boolean[] array)
Checks if an array of primitive booleans is not empty or not null.
array - the array to testtrue if the array is not empty or not nullpublic Object[] addAll(Object[] array1, Object[] array2)
Adds all the elements of the given arrays into a new array.
The new array contains all of the element of array1 followed
by all of the elements array2. When an array is returned, it is always
a new array.
ArrayUtils.addAll(null, null) = null ArrayUtils.addAll(array1, null) = cloned copy of array1 ArrayUtils.addAll(null, array2) = cloned copy of array2 ArrayUtils.addAll([], []) = [] ArrayUtils.addAll([null], [null]) = [null, null] ArrayUtils.addAll(["a", "b", "c"], ["1", "2", "3"]) = ["a", "b", "c", "1", "2", "3"]
array1 - the first array whose elements are added to the new array, may be nullarray2 - the second array whose elements are added to the new array, may be nullnull if both arrays are null.
The type of the new array is the type of the first array,
unless the first array is null, in which case the type is the same as the second array.IllegalArgumentException - if the array types are incompatiblepublic boolean[] addAll(boolean[] array1,
boolean[] array2)
Adds all the elements of the given arrays into a new array.
The new array contains all of the element of array1 followed
by all of the elements array2. When an array is returned, it is always
a new array.
ArrayUtils.addAll(array1, null) = cloned copy of array1 ArrayUtils.addAll(null, array2) = cloned copy of array2 ArrayUtils.addAll([], []) = []
array1 - the first array whose elements are added to the new array.array2 - the second array whose elements are added to the new array.public char[] addAll(char[] array1,
char[] array2)
Adds all the elements of the given arrays into a new array.
The new array contains all of the element of array1 followed
by all of the elements array2. When an array is returned, it is always
a new array.
ArrayUtils.addAll(array1, null) = cloned copy of array1 ArrayUtils.addAll(null, array2) = cloned copy of array2 ArrayUtils.addAll([], []) = []
array1 - the first array whose elements are added to the new array.array2 - the second array whose elements are added to the new array.public byte[] addAll(byte[] array1,
byte[] array2)
Adds all the elements of the given arrays into a new array.
The new array contains all of the element of array1 followed
by all of the elements array2. When an array is returned, it is always
a new array.
ArrayUtils.addAll(array1, null) = cloned copy of array1 ArrayUtils.addAll(null, array2) = cloned copy of array2 ArrayUtils.addAll([], []) = []
array1 - the first array whose elements are added to the new array.array2 - the second array whose elements are added to the new array.public short[] addAll(short[] array1,
short[] array2)
Adds all the elements of the given arrays into a new array.
The new array contains all of the element of array1 followed
by all of the elements array2. When an array is returned, it is always
a new array.
ArrayUtils.addAll(array1, null) = cloned copy of array1 ArrayUtils.addAll(null, array2) = cloned copy of array2 ArrayUtils.addAll([], []) = []
array1 - the first array whose elements are added to the new array.array2 - the second array whose elements are added to the new array.public int[] addAll(int[] array1,
int[] array2)
Adds all the elements of the given arrays into a new array.
The new array contains all of the element of array1 followed
by all of the elements array2. When an array is returned, it is always
a new array.
ArrayUtils.addAll(array1, null) = cloned copy of array1 ArrayUtils.addAll(null, array2) = cloned copy of array2 ArrayUtils.addAll([], []) = []
array1 - the first array whose elements are added to the new array.array2 - the second array whose elements are added to the new array.public long[] addAll(long[] array1,
long[] array2)
Adds all the elements of the given arrays into a new array.
The new array contains all of the element of array1 followed
by all of the elements array2. When an array is returned, it is always
a new array.
ArrayUtils.addAll(array1, null) = cloned copy of array1 ArrayUtils.addAll(null, array2) = cloned copy of array2 ArrayUtils.addAll([], []) = []
array1 - the first array whose elements are added to the new array.array2 - the second array whose elements are added to the new array.public float[] addAll(float[] array1,
float[] array2)
Adds all the elements of the given arrays into a new array.
The new array contains all of the element of array1 followed
by all of the elements array2. When an array is returned, it is always
a new array.
ArrayUtils.addAll(array1, null) = cloned copy of array1 ArrayUtils.addAll(null, array2) = cloned copy of array2 ArrayUtils.addAll([], []) = []
array1 - the first array whose elements are added to the new array.array2 - the second array whose elements are added to the new array.public double[] addAll(double[] array1,
double[] array2)
Adds all the elements of the given arrays into a new array.
The new array contains all of the element of array1 followed
by all of the elements array2. When an array is returned, it is always
a new array.
ArrayUtils.addAll(array1, null) = cloned copy of array1 ArrayUtils.addAll(null, array2) = cloned copy of array2 ArrayUtils.addAll([], []) = []
array1 - the first array whose elements are added to the new array.array2 - the second array whose elements are added to the new array.public Object[] add(Object[] array, Object element)
Copies the given array and adds the given element at the end of the new array.
The new array contains the same elements of the input array plus the given element in the last position. The component type of the new array is the same as that of the input array.
If the input array is null, a new one element array is returned
whose component type is the same as the element, unless the element itself is null,
in which case the return type is Object[]
ArrayUtils.add(null, null) = [null] ArrayUtils.add(null, "a") = ["a"] ArrayUtils.add(["a"], null) = ["a", null] ArrayUtils.add(["a"], "b") = ["a", "b"] ArrayUtils.add(["a", "b"], "c") = ["a", "b", "c"]
array - the array to "add" the element to, may be nullelement - the object to add, may be nullpublic boolean[] add(boolean[] array,
boolean element)
Copies the given array and adds the given element at the end of the new array.
The new array contains the same elements of the input array plus the given element in the last position. The component type of the new array is the same as that of the input array.
If the input array is null, a new one element array is returned
whose component type is the same as the element.
ArrayUtils.add(null, true) = [true] ArrayUtils.add([true], false) = [true, false] ArrayUtils.add([true, false], true) = [true, false, true]
array - the array to copy and add the element to, may be nullelement - the object to add at the last index of the new arraypublic byte[] add(byte[] array,
byte element)
Copies the given array and adds the given element at the end of the new array.
The new array contains the same elements of the input array plus the given element in the last position. The component type of the new array is the same as that of the input array.
If the input array is null, a new one element array is returned
whose component type is the same as the element.
ArrayUtils.add(null, 0) = [0] ArrayUtils.add([1], 0) = [1, 0] ArrayUtils.add([1, 0], 1) = [1, 0, 1]
array - the array to copy and add the element to, may be nullelement - the object to add at the last index of the new arraypublic char[] add(char[] array,
char element)
Copies the given array and adds the given element at the end of the new array.
The new array contains the same elements of the input array plus the given element in the last position. The component type of the new array is the same as that of the input array.
If the input array is null, a new one element array is returned
whose component type is the same as the element.
ArrayUtils.add(null, '0') = ['0'] ArrayUtils.add(['1'], '0') = ['1', '0'] ArrayUtils.add(['1', '0'], '1') = ['1', '0', '1']
array - the array to copy and add the element to, may be nullelement - the object to add at the last index of the new arraypublic double[] add(double[] array,
double element)
Copies the given array and adds the given element at the end of the new array.
The new array contains the same elements of the input array plus the given element in the last position. The component type of the new array is the same as that of the input array.
If the input array is null, a new one element array is returned
whose component type is the same as the element.
ArrayUtils.add(null, 0) = [0] ArrayUtils.add([1], 0) = [1, 0] ArrayUtils.add([1, 0], 1) = [1, 0, 1]
array - the array to copy and add the element to, may be nullelement - the object to add at the last index of the new arraypublic float[] add(float[] array,
float element)
Copies the given array and adds the given element at the end of the new array.
The new array contains the same elements of the input array plus the given element in the last position. The component type of the new array is the same as that of the input array.
If the input array is null, a new one element array is returned
whose component type is the same as the element.
ArrayUtils.add(null, 0) = [0] ArrayUtils.add([1], 0) = [1, 0] ArrayUtils.add([1, 0], 1) = [1, 0, 1]
array - the array to copy and add the element to, may be nullelement - the object to add at the last index of the new arraypublic int[] add(int[] array,
int element)
Copies the given array and adds the given element at the end of the new array.
The new array contains the same elements of the input array plus the given element in the last position. The component type of the new array is the same as that of the input array.
If the input array is null, a new one element array is returned
whose component type is the same as the element.
ArrayUtils.add(null, 0) = [0] ArrayUtils.add([1], 0) = [1, 0] ArrayUtils.add([1, 0], 1) = [1, 0, 1]
array - the array to copy and add the element to, may be nullelement - the object to add at the last index of the new arraypublic long[] add(long[] array,
long element)
Copies the given array and adds the given element at the end of the new array.
The new array contains the same elements of the input array plus the given element in the last position. The component type of the new array is the same as that of the input array.
If the input array is null, a new one element array is returned
whose component type is the same as the element.
ArrayUtils.add(null, 0) = [0] ArrayUtils.add([1], 0) = [1, 0] ArrayUtils.add([1, 0], 1) = [1, 0, 1]
array - the array to copy and add the element to, may be nullelement - the object to add at the last index of the new arraypublic short[] add(short[] array,
short element)
Copies the given array and adds the given element at the end of the new array.
The new array contains the same elements of the input array plus the given element in the last position. The component type of the new array is the same as that of the input array.
If the input array is null, a new one element array is returned
whose component type is the same as the element.
ArrayUtils.add(null, 0) = [0] ArrayUtils.add([1], 0) = [1, 0] ArrayUtils.add([1, 0], 1) = [1, 0, 1]
array - the array to copy and add the element to, may be nullelement - the object to add at the last index of the new arraypublic Object[] add(Object[] array, int index, Object element)
Inserts the specified element at the specified position in the array. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
This method returns a new array with the same elements of the input array plus the given element on the specified position. The component type of the returned array is always the same as that of the input array.
If the input array is null, a new one element array is returned
whose component type is the same as the element.
ArrayUtils.add(null, 0, null) = [null] ArrayUtils.add(null, 0, "a") = ["a"] ArrayUtils.add(["a"], 1, null) = ["a", null] ArrayUtils.add(["a"], 1, "b") = ["a", "b"] ArrayUtils.add(["a", "b"], 3, "c") = ["a", "b", "c"]
array - the array to add the element to, may be nullindex - the position of the new objectelement - the object to addIndexOutOfBoundsException - if the index is out of range
(index < 0 || index > array.length).public <T> T[] addAll(T[]... arrays)
T - 数组元素类型arrays - 数组集合public <T> T[] newArray(Class<?> componentType, int newSize)
T - 数组元素类型componentType - 元素类型newSize - 大小public char[] add(char[] array,
int index,
char element)
Inserts the specified element at the specified position in the array. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
This method returns a new array with the same elements of the input array plus the given element on the specified position. The component type of the returned array is always the same as that of the input array.
If the input array is null, a new one element array is returned
whose component type is the same as the element.
ArrayUtils.add(null, 0, 'a') = ['a'] ArrayUtils.add(['a'], 0, 'b') = ['b', 'a'] ArrayUtils.add(['a', 'b'], 0, 'c') = ['c', 'a', 'b'] ArrayUtils.add(['a', 'b'], 1, 'k') = ['a', 'k', 'b'] ArrayUtils.add(['a', 'b', 'c'], 1, 't') = ['a', 't', 'b', 'c']
array - the array to add the element to, may be nullindex - the position of the new objectelement - the object to addIndexOutOfBoundsException - if the index is out of range
(index < 0 || index > array.length).public byte[] add(byte[] array,
int index,
byte element)
Inserts the specified element at the specified position in the array. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
This method returns a new array with the same elements of the input array plus the given element on the specified position. The component type of the returned array is always the same as that of the input array.
If the input array is null, a new one element array is returned
whose component type is the same as the element.
ArrayUtils.add([1], 0, 2) = [2, 1] ArrayUtils.add([2, 6], 2, 3) = [2, 6, 3] ArrayUtils.add([2, 6], 0, 1) = [1, 2, 6] ArrayUtils.add([2, 6, 3], 2, 1) = [2, 6, 1, 3]
array - the array to add the element to, may be nullindex - the position of the new objectelement - the object to addIndexOutOfBoundsException - if the index is out of range
(index < 0 || index > array.length).public short[] add(short[] array,
int index,
short element)
Inserts the specified element at the specified position in the array. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
This method returns a new array with the same elements of the input array plus the given element on the specified position. The component type of the returned array is always the same as that of the input array.
If the input array is null, a new one element array is returned
whose component type is the same as the element.
ArrayUtils.add([1], 0, 2) = [2, 1] ArrayUtils.add([2, 6], 2, 10) = [2, 6, 10] ArrayUtils.add([2, 6], 0, -4) = [-4, 2, 6] ArrayUtils.add([2, 6, 3], 2, 1) = [2, 6, 1, 3]
array - the array to add the element to, may be nullindex - the position of the new objectelement - the object to addIndexOutOfBoundsException - if the index is out of range
(index < 0 || index > array.length).public int[] add(int[] array,
int index,
int element)
Inserts the specified element at the specified position in the array. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
This method returns a new array with the same elements of the input array plus the given element on the specified position. The component type of the returned array is always the same as that of the input array.
If the input array is null, a new one element array is returned
whose component type is the same as the element.
ArrayUtils.add([1], 0, 2) = [2, 1] ArrayUtils.add([2, 6], 2, 10) = [2, 6, 10] ArrayUtils.add([2, 6], 0, -4) = [-4, 2, 6] ArrayUtils.add([2, 6, 3], 2, 1) = [2, 6, 1, 3]
array - the array to add the element to, may be nullindex - the position of the new objectelement - the object to addIndexOutOfBoundsException - if the index is out of range
(index < 0 || index > array.length).public long[] add(long[] array,
int index,
long element)
Inserts the specified element at the specified position in the array. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
This method returns a new array with the same elements of the input array plus the given element on the specified position. The component type of the returned array is always the same as that of the input array.
If the input array is null, a new one element array is returned
whose component type is the same as the element.
ArrayUtils.add([1L], 0, 2L) = [2L, 1L] ArrayUtils.add([2L, 6L], 2, 10L) = [2L, 6L, 10L] ArrayUtils.add([2L, 6L], 0, -4L) = [-4L, 2L, 6L] ArrayUtils.add([2L, 6L, 3L], 2, 1L) = [2L, 6L, 1L, 3L]
array - the array to add the element to, may be nullindex - the position of the new objectelement - the object to addIndexOutOfBoundsException - if the index is out of range
(index < 0 || index > array.length).public float[] add(float[] array,
int index,
float element)
Inserts the specified element at the specified position in the array. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
This method returns a new array with the same elements of the input array plus the given element on the specified position. The component type of the returned array is always the same as that of the input array.
If the input array is null, a new one element array is returned
whose component type is the same as the element.
ArrayUtils.add([1.1f], 0, 2.2f) = [2.2f, 1.1f] ArrayUtils.add([2.3f, 6.4f], 2, 10.5f) = [2.3f, 6.4f, 10.5f] ArrayUtils.add([2.6f, 6.7f], 0, -4.8f) = [-4.8f, 2.6f, 6.7f] ArrayUtils.add([2.9f, 6.0f, 0.3f], 2, 1.0f) = [2.9f, 6.0f, 1.0f, 0.3f]
array - the array to add the element to, may be nullindex - the position of the new objectelement - the object to addIndexOutOfBoundsException - if the index is out of range
(index < 0 || index > array.length).public double[] add(double[] array,
int index,
double element)
Inserts the specified element at the specified position in the array. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
This method returns a new array with the same elements of the input array plus the given element on the specified position. The component type of the returned array is always the same as that of the input array.
If the input array is null, a new one element array is returned
whose component type is the same as the element.
ArrayUtils.add([1.1], 0, 2.2) = [2.2, 1.1] ArrayUtils.add([2.3, 6.4], 2, 10.5) = [2.3, 6.4, 10.5] ArrayUtils.add([2.6, 6.7], 0, -4.8) = [-4.8, 2.6, 6.7] ArrayUtils.add([2.9, 6.0, 0.3], 2, 1.0) = [2.9, 6.0, 1.0, 0.3]
array - the array to add the element to, may be nullindex - the position of the new objectelement - the object to addIndexOutOfBoundsException - if the index is out of range
(index < 0 || index > array.length).public Object[] remove(Object[] array, int index)
Removes the element at the specified position from the specified array. All subsequent elements are shifted to the left (substracts one from their indices).
This method returns a new array with the same elements of the input array except the element on the specified position. The component type of the returned array is always the same as that of the input array.
If the input array is null, an IndexOutOfBoundsException
will be thrown, because in that case no valid index can be specified.
ArrayUtils.remove(["a"], 0) = [] ArrayUtils.remove(["a", "b"], 0) = ["b"] ArrayUtils.remove(["a", "b"], 1) = ["a"] ArrayUtils.remove(["a", "b", "c"], 1) = ["a", "c"]
array - the array to remove the element from, may not be nullindex - the position of the element to be removedIndexOutOfBoundsException - if the index is out of range
(index < 0 || index >= array.length), or if the array is null.public Object[] removeElement(Object[] array, Object element)
Removes the first occurrence of the specified element from the specified array. All subsequent elements are shifted to the left (substracts one from their indices). If the array doesn't contains such an element, no elements are removed from the array.
This method returns a new array with the same elements of the input array except the first occurrence of the specified element. The component type of the returned array is always the same as that of the input array.
ArrayUtils.removeElement(null, "a") = null ArrayUtils.removeElement([], "a") = [] ArrayUtils.removeElement(["a"], "b") = ["a"] ArrayUtils.removeElement(["a", "b"], "a") = ["b"] ArrayUtils.removeElement(["a", "b", "a"], "a") = ["b", "a"]
array - the array to remove the element from, may be nullelement - the element to be removedpublic boolean[] remove(boolean[] array,
int index)
Removes the element at the specified position from the specified array. All subsequent elements are shifted to the left (substracts one from their indices).
This method returns a new array with the same elements of the input array except the element on the specified position. The component type of the returned array is always the same as that of the input array.
If the input array is null, an IndexOutOfBoundsException
will be thrown, because in that case no valid index can be specified.
ArrayUtils.remove([true], 0) = [] ArrayUtils.remove([true, false], 0) = [false] ArrayUtils.remove([true, false], 1) = [true] ArrayUtils.remove([true, true, false], 1) = [true, false]
array - the array to remove the element from, may not be nullindex - the position of the element to be removedIndexOutOfBoundsException - if the index is out of range
(index < 0 || index >= array.length), or if the array is null.public boolean[] removeElement(boolean[] array,
boolean element)
Removes the first occurrence of the specified element from the specified array. All subsequent elements are shifted to the left (substracts one from their indices). If the array doesn't contains such an element, no elements are removed from the array.
This method returns a new array with the same elements of the input array except the first occurrence of the specified element. The component type of the returned array is always the same as that of the input array.
ArrayUtils.removeElement(null, true) = null ArrayUtils.removeElement([], true) = [] ArrayUtils.removeElement([true], false) = [true] ArrayUtils.removeElement([true, false], false) = [true] ArrayUtils.removeElement([true, false, true], true) = [false, true]
array - the array to remove the element from, may be nullelement - the element to be removedpublic byte[] remove(byte[] array,
int index)
Removes the element at the specified position from the specified array. All subsequent elements are shifted to the left (substracts one from their indices).
This method returns a new array with the same elements of the input array except the element on the specified position. The component type of the returned array is always the same as that of the input array.
If the input array is null, an IndexOutOfBoundsException
will be thrown, because in that case no valid index can be specified.
ArrayUtils.remove([1], 0) = [] ArrayUtils.remove([1, 0], 0) = [0] ArrayUtils.remove([1, 0], 1) = [1] ArrayUtils.remove([1, 0, 1], 1) = [1, 1]
array - the array to remove the element from, may not be nullindex - the position of the element to be removedIndexOutOfBoundsException - if the index is out of range
(index < 0 || index >= array.length), or if the array is null.public byte[] removeElement(byte[] array,
byte element)
Removes the first occurrence of the specified element from the specified array. All subsequent elements are shifted to the left (substracts one from their indices). If the array doesn't contains such an element, no elements are removed from the array.
This method returns a new array with the same elements of the input array except the first occurrence of the specified element. The component type of the returned array is always the same as that of the input array.
ArrayUtils.removeElement(null, 1) = null ArrayUtils.removeElement([], 1) = [] ArrayUtils.removeElement([1], 0) = [1] ArrayUtils.removeElement([1, 0], 0) = [1] ArrayUtils.removeElement([1, 0, 1], 1) = [0, 1]
array - the array to remove the element from, may be nullelement - the element to be removedpublic char[] remove(char[] array,
int index)
Removes the element at the specified position from the specified array. All subsequent elements are shifted to the left (substracts one from their indices).
This method returns a new array with the same elements of the input array except the element on the specified position. The component type of the returned array is always the same as that of the input array.
If the input array is null, an IndexOutOfBoundsException
will be thrown, because in that case no valid index can be specified.
ArrayUtils.remove(['a'], 0) = [] ArrayUtils.remove(['a', 'b'], 0) = ['b'] ArrayUtils.remove(['a', 'b'], 1) = ['a'] ArrayUtils.remove(['a', 'b', 'c'], 1) = ['a', 'c']
array - the array to remove the element from, may not be nullindex - the position of the element to be removedIndexOutOfBoundsException - if the index is out of range
(index < 0 || index >= array.length), or if the array is null.public char[] removeElement(char[] array,
char element)
Removes the first occurrence of the specified element from the specified array. All subsequent elements are shifted to the left (substracts one from their indices). If the array doesn't contains such an element, no elements are removed from the array.
This method returns a new array with the same elements of the input array except the first occurrence of the specified element. The component type of the returned array is always the same as that of the input array.
ArrayUtils.removeElement(null, 'a') = null ArrayUtils.removeElement([], 'a') = [] ArrayUtils.removeElement(['a'], 'b') = ['a'] ArrayUtils.removeElement(['a', 'b'], 'a') = ['b'] ArrayUtils.removeElement(['a', 'b', 'a'], 'a') = ['b', 'a']
array - the array to remove the element from, may be nullelement - the element to be removedpublic double[] remove(double[] array,
int index)
Removes the element at the specified position from the specified array. All subsequent elements are shifted to the left (substracts one from their indices).
This method returns a new array with the same elements of the input array except the element on the specified position. The component type of the returned array is always the same as that of the input array.
If the input array is null, an IndexOutOfBoundsException
will be thrown, because in that case no valid index can be specified.
ArrayUtils.remove([1.1], 0) = [] ArrayUtils.remove([2.5, 6.0], 0) = [6.0] ArrayUtils.remove([2.5, 6.0], 1) = [2.5] ArrayUtils.remove([2.5, 6.0, 3.8], 1) = [2.5, 3.8]
array - the array to remove the element from, may not be nullindex - the position of the element to be removedIndexOutOfBoundsException - if the index is out of range
(index < 0 || index >= array.length), or if the array is null.public double[] removeElement(double[] array,
double element)
Removes the first occurrence of the specified element from the specified array. All subsequent elements are shifted to the left (substracts one from their indices). If the array doesn't contains such an element, no elements are removed from the array.
This method returns a new array with the same elements of the input array except the first occurrence of the specified element. The component type of the returned array is always the same as that of the input array.
ArrayUtils.removeElement(null, 1.1) = null ArrayUtils.removeElement([], 1.1) = [] ArrayUtils.removeElement([1.1], 1.2) = [1.1] ArrayUtils.removeElement([1.1, 2.3], 1.1) = [2.3] ArrayUtils.removeElement([1.1, 2.3, 1.1], 1.1) = [2.3, 1.1]
array - the array to remove the element from, may be nullelement - the element to be removedpublic float[] remove(float[] array,
int index)
Removes the element at the specified position from the specified array. All subsequent elements are shifted to the left (substracts one from their indices).
This method returns a new array with the same elements of the input array except the element on the specified position. The component type of the returned array is always the same as that of the input array.
If the input array is null, an IndexOutOfBoundsException
will be thrown, because in that case no valid index can be specified.
ArrayUtils.remove([1.1], 0) = [] ArrayUtils.remove([2.5, 6.0], 0) = [6.0] ArrayUtils.remove([2.5, 6.0], 1) = [2.5] ArrayUtils.remove([2.5, 6.0, 3.8], 1) = [2.5, 3.8]
array - the array to remove the element from, may not be nullindex - the position of the element to be removedIndexOutOfBoundsException - if the index is out of range
(index < 0 || index >= array.length), or if the array is null.public float[] removeElement(float[] array,
float element)
Removes the first occurrence of the specified element from the specified array. All subsequent elements are shifted to the left (substracts one from their indices). If the array doesn't contains such an element, no elements are removed from the array.
This method returns a new array with the same elements of the input array except the first occurrence of the specified element. The component type of the returned array is always the same as that of the input array.
ArrayUtils.removeElement(null, 1.1) = null ArrayUtils.removeElement([], 1.1) = [] ArrayUtils.removeElement([1.1], 1.2) = [1.1] ArrayUtils.removeElement([1.1, 2.3], 1.1) = [2.3] ArrayUtils.removeElement([1.1, 2.3, 1.1], 1.1) = [2.3, 1.1]
array - the array to remove the element from, may be nullelement - the element to be removedpublic int[] remove(int[] array,
int index)
Removes the element at the specified position from the specified array. All subsequent elements are shifted to the left (substracts one from their indices).
This method returns a new array with the same elements of the input array except the element on the specified position. The component type of the returned array is always the same as that of the input array.
If the input array is null, an IndexOutOfBoundsException
will be thrown, because in that case no valid index can be specified.
ArrayUtils.remove([1], 0) = [] ArrayUtils.remove([2, 6], 0) = [6] ArrayUtils.remove([2, 6], 1) = [2] ArrayUtils.remove([2, 6, 3], 1) = [2, 3]
array - the array to remove the element from, may not be nullindex - the position of the element to be removedIndexOutOfBoundsException - if the index is out of range
(index < 0 || index >= array.length), or if the array is null.public int[] removeElement(int[] array,
int element)
Removes the first occurrence of the specified element from the specified array. All subsequent elements are shifted to the left (substracts one from their indices). If the array doesn't contains such an element, no elements are removed from the array.
This method returns a new array with the same elements of the input array except the first occurrence of the specified element. The component type of the returned array is always the same as that of the input array.
ArrayUtils.removeElement(null, 1) = null ArrayUtils.removeElement([], 1) = [] ArrayUtils.removeElement([1], 2) = [1] ArrayUtils.removeElement([1, 3], 1) = [3] ArrayUtils.removeElement([1, 3, 1], 1) = [3, 1]
array - the array to remove the element from, may be nullelement - the element to be removedpublic long[] remove(long[] array,
int index)
Removes the element at the specified position from the specified array. All subsequent elements are shifted to the left (substracts one from their indices).
This method returns a new array with the same elements of the input array except the element on the specified position. The component type of the returned array is always the same as that of the input array.
If the input array is null, an IndexOutOfBoundsException
will be thrown, because in that case no valid index can be specified.
ArrayUtils.remove([1], 0) = [] ArrayUtils.remove([2, 6], 0) = [6] ArrayUtils.remove([2, 6], 1) = [2] ArrayUtils.remove([2, 6, 3], 1) = [2, 3]
array - the array to remove the element from, may not be nullindex - the position of the element to be removedIndexOutOfBoundsException - if the index is out of range
(index < 0 || index >= array.length), or if the array is null.public long[] removeElement(long[] array,
long element)
Removes the first occurrence of the specified element from the specified array. All subsequent elements are shifted to the left (substracts one from their indices). If the array doesn't contains such an element, no elements are removed from the array.
This method returns a new array with the same elements of the input array except the first occurrence of the specified element. The component type of the returned array is always the same as that of the input array.
ArrayUtils.removeElement(null, 1) = null ArrayUtils.removeElement([], 1) = [] ArrayUtils.removeElement([1], 2) = [1] ArrayUtils.removeElement([1, 3], 1) = [3] ArrayUtils.removeElement([1, 3, 1], 1) = [3, 1]
array - the array to remove the element from, may be nullelement - the element to be removedpublic short[] remove(short[] array,
int index)
Removes the element at the specified position from the specified array. All subsequent elements are shifted to the left (substracts one from their indices).
This method returns a new array with the same elements of the input array except the element on the specified position. The component type of the returned array is always the same as that of the input array.
If the input array is null, an IndexOutOfBoundsException
will be thrown, because in that case no valid index can be specified.
ArrayUtils.remove([1], 0) = [] ArrayUtils.remove([2, 6], 0) = [6] ArrayUtils.remove([2, 6], 1) = [2] ArrayUtils.remove([2, 6, 3], 1) = [2, 3]
array - the array to remove the element from, may not be nullindex - the position of the element to be removedIndexOutOfBoundsException - if the index is out of range
(index < 0 || index >= array.length), or if the array is null.public short[] removeElement(short[] array,
short element)
Removes the first occurrence of the specified element from the specified array. All subsequent elements are shifted to the left (substracts one from their indices). If the array doesn't contains such an element, no elements are removed from the array.
This method returns a new array with the same elements of the input array except the first occurrence of the specified element. The component type of the returned array is always the same as that of the input array.
ArrayUtils.removeElement(null, 1) = null ArrayUtils.removeElement([], 1) = [] ArrayUtils.removeElement([1], 2) = [1] ArrayUtils.removeElement([1, 3], 1) = [3] ArrayUtils.removeElement([1, 3, 1], 1) = [3, 1]
array - the array to remove the element from, may be nullelement - the element to be removedCopyright © 2017. All rights reserved.