public class ArrayUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static boolean[] |
EMPTY_BOOLEAN_ARRAY
boolean array. |
static Boolean[] |
EMPTY_BOOLEAN_OBJECT_ARRAY
Boolean array. |
static byte[] |
EMPTY_BYTE_ARRAY
byte array. |
static Byte[] |
EMPTY_BYTE_OBJECT_ARRAY
Byte array. |
static char[] |
EMPTY_CHAR_ARRAY
char array. |
static Character[] |
EMPTY_CHARACTER_OBJECT_ARRAY
Character array. |
static Class<?>[] |
EMPTY_CLASS_ARRAY
Class array. |
static double[] |
EMPTY_DOUBLE_ARRAY
double array. |
static Double[] |
EMPTY_DOUBLE_OBJECT_ARRAY
Double array. |
static float[] |
EMPTY_FLOAT_ARRAY
float array. |
static Float[] |
EMPTY_FLOAT_OBJECT_ARRAY
Float array. |
static int[] |
EMPTY_INT_ARRAY
int array. |
static Integer[] |
EMPTY_INTEGER_OBJECT_ARRAY
Integer array. |
static long[] |
EMPTY_LONG_ARRAY
long array. |
static Long[] |
EMPTY_LONG_OBJECT_ARRAY
Long array. |
static Object[] |
EMPTY_OBJECT_ARRAY
Object array. |
static short[] |
EMPTY_SHORT_ARRAY
short array. |
static Short[] |
EMPTY_SHORT_OBJECT_ARRAY
Short array. |
static String[] |
EMPTY_STRING_ARRAY
String array. |
static int |
INDEX_NOT_FOUND
列表或数组中没有找到元素时的索引值 :
-1. |
| Constructor and Description |
|---|
ArrayUtils() |
| Modifier and Type | Method and Description |
|---|---|
static boolean[] |
add(boolean[] array,
boolean element)
Copies the given array and adds the given element at the end of the new array.
|
static boolean[] |
add(boolean[] array,
int index,
boolean element)
Inserts the specified element at the specified position in the array.
|
static byte[] |
add(byte[] array,
byte element)
Copies the given array and adds the given element at the end of the new array.
|
static byte[] |
add(byte[] array,
int index,
byte element)
Inserts the specified element at the specified position in the array.
|
static char[] |
add(char[] array,
char element)
Copies the given array and adds the given element at the end of the new array.
|
static char[] |
add(char[] array,
int index,
char element)
Inserts the specified element at the specified position in the array.
|
static double[] |
add(double[] array,
double element)
Copies the given array and adds the given element at the end of the new array.
|
static double[] |
add(double[] array,
int index,
double element)
Inserts the specified element at the specified position in the array.
|
static float[] |
add(float[] array,
float element)
Copies the given array and adds the given element at the end of the new array.
|
static float[] |
add(float[] array,
int index,
float element)
Inserts the specified element at the specified position in the array.
|
static int[] |
add(int[] array,
int element)
Copies the given array and adds the given element at the end of the new array.
|
static int[] |
add(int[] array,
int index,
int element)
Inserts the specified element at the specified position in the array.
|
static long[] |
add(long[] array,
int index,
long element)
Inserts the specified element at the specified position in the array.
|
static long[] |
add(long[] array,
long element)
Copies the given array and adds the given element at the end of the new array.
|
static short[] |
add(short[] array,
int index,
short element)
Inserts the specified element at the specified position in the array.
|
static short[] |
add(short[] array,
short element)
Copies the given array and adds the given element at the end of the new array.
|
static <T> T[] |
add(T[] array,
int index,
T element)
Inserts the specified element at the specified position in the array.
|
static <T> T[] |
add(T[] array,
T element)
Copies the given array and adds the given element at the end of the new array.
|
static boolean[] |
addAll(boolean[] array1,
boolean... array2)
Adds all the elements of the given arrays into a new array.
|
static byte[] |
addAll(byte[] array1,
byte... array2)
Adds all the elements of the given arrays into a new array.
|
static char[] |
addAll(char[] array1,
char... array2)
Adds all the elements of the given arrays into a new array.
|
static double[] |
addAll(double[] array1,
double... array2)
Adds all the elements of the given arrays into a new array.
|
static float[] |
addAll(float[] array1,
float... array2)
Adds all the elements of the given arrays into a new array.
|
static int[] |
addAll(int[] array1,
int... array2)
Adds all the elements of the given arrays into a new array.
|
static long[] |
addAll(long[] array1,
long... array2)
Adds all the elements of the given arrays into a new array.
|
static short[] |
addAll(short[] array1,
short... array2)
Adds all the elements of the given arrays into a new array.
|
static <T> T[] |
addAll(T[]... arrays)
将多个数组合并在一起
忽略null的数组 |
static <T> T[] |
addAll(T[] array1,
T... array2)
Adds all the elements of the given arrays into a new array.
|
static <T> Object |
append(Object array,
T... newElements)
将新元素添加到已有数组中
添加新元素会生成一个新的数组,不影响原数组 |
static <T> T[] |
append(T[] buffer,
T... newElements)
将新元素添加到已有数组中
添加新元素会生成一个新的数组,不影响原数组 |
static Object[] |
cast(Class<?> type,
Object arrayObj)
强转数组类型
强制转换的前提是数组元素类型可被强制转换 强制转换后会生成一个新数组 |
static boolean[] |
clone(boolean[] array)
克隆数组
|
static byte[] |
clone(byte[] array)
克隆数组
|
static char[] |
clone(char[] array)
克隆数组
|
static double[] |
clone(double[] array)
克隆数组
|
static float[] |
clone(float[] array)
克隆数组
|
static int[] |
clone(int[] array)
克隆数组
|
static long[] |
clone(long[] array)
克隆数组
|
static short[] |
clone(short[] array)
克隆数组
|
static <T> T |
clone(T obj)
克隆数组,如果非数组返回null
|
static <T> T[] |
clone(T[] array)
克隆数组
|
static boolean |
contains(boolean[] array,
boolean value)
数组中是否包含元素
|
static boolean |
contains(byte[] array,
byte value)
数组中是否包含元素
|
static boolean |
contains(char[] array,
char value)
数组中是否包含元素
|
static boolean |
contains(double[] array,
double value)
数组中是否包含元素
|
static boolean |
contains(double[] array,
double value,
double tolerance)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static boolean |
contains(float[] array,
float value)
数组中是否包含元素
|
static boolean |
contains(int[] array,
int value)
数组中是否包含元素
|
static boolean |
contains(long[] array,
long value)
数组中是否包含元素
|
static boolean |
contains(Object[] array,
Object value)
数组中是否包含元素
|
static boolean |
contains(short[] array,
short value)
数组中是否包含元素
|
static boolean |
containsIgnoreCase(CharSequence[] array,
CharSequence value)
数组中是否包含元素,忽略大小写
|
static Object |
copy(Object src,
int srcPos,
Object dest,
int destPos,
int length)
|
static Object |
copy(Object src,
Object dest,
int length)
包装
System.arraycopy(Object, int, Object, int, int)数组复制,缘数组和目标数组都是从位置0开始复制 |
static <T> T[] |
filter(T[] array,
Editor<T> editor)
过滤
过滤过程通过传入的Editor实现来返回需要的元素内容,这个Editor实现可以实现以下功能: |
static <T> T[] |
filter(T[] array,
Filter<T> filter)
过滤
过滤过程通过传入的Filter实现来过滤返回需要的元素内容,这个Editor实现可以实现以下功能: |
static <T> T |
firstNonNull(T... array)
返回数组中第一个非空元素
|
static Optional<Object> |
firstNotNullElem(Object[] objects)
找到第一个不为 null 的元素
|
static <T> T |
get(Object array,
int index)
获取数组对象中指定index的值,支持负数,例如-1表示倒数第一个值
|
static <T> T[] |
getAny(Object array,
int... indexes)
获取数组中指定多个下标元素值,组成新数组
|
static Class<?> |
getArrayType(Class<?> componentType)
根据数组元素类型,获取数组的类型
方法是通过创建一个空数组从而获取其类型 |
static Class<?> |
getComponentType(Class<?> arrayClass)
获取数组对象的元素类型
|
static Class<?> |
getComponentType(Object array)
获取数组对象的元素类型
|
static int |
getLength(Object array)
返回指定数组的长度
|
static int |
hashCode(Object array)
获得一个数组哈希码,用于正确处理多维数组。
多维基元数组也可以用该方法正确处理。
|
static <T> boolean |
hasNull(T... array)
是否包含
null元素 |
static int |
indexOf(boolean[] array,
boolean value)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static int |
indexOf(boolean[] array,
boolean value,
int index)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static int |
indexOf(byte[] array,
byte value)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static int |
indexOf(byte[] array,
byte value,
int index)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static int |
indexOf(char[] array,
char value)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static int |
indexOf(char[] array,
char value,
int index)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static int |
indexOf(double[] array,
double value)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static int |
indexOf(double[] array,
double value,
double tolerance)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static int |
indexOf(double[] array,
double value,
int index)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static int |
indexOf(double[] array,
double value,
int index,
double tolerance)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static int |
indexOf(float[] array,
float value)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static int |
indexOf(float[] array,
float value,
int index)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static int |
indexOf(int[] array,
int value)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static int |
indexOf(int[] array,
int value,
int index)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static int |
indexOf(long[] array,
long value)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static int |
indexOf(long[] array,
long value,
int index)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static int |
indexOf(Object[] array,
Object value)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static int |
indexOf(Object[] array,
Object value,
int index)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static int |
indexOf(short[] array,
short value)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static int |
indexOf(short[] array,
short value,
int index)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static int |
indexOfIgnoreCase(CharSequence[] array,
CharSequence value)
返回数组中指定元素所在位置,忽略大小写,未找到返回
INDEX_NOT_FOUND |
static boolean[] |
insert(int index,
boolean[] array,
boolean... values)
Inserts elements into an array at the given index (starting from zero).
|
static byte[] |
insert(int index,
byte[] array,
byte... values)
Inserts elements into an array at the given index (starting from zero).
|
static char[] |
insert(int index,
char[] array,
char... values)
Inserts elements into an array at the given index (starting from zero).
|
static double[] |
insert(int index,
double[] array,
double... values)
Inserts elements into an array at the given index (starting from zero).
|
static float[] |
insert(int index,
float[] array,
float... values)
Inserts elements into an array at the given index (starting from zero).
|
static int[] |
insert(int index,
int[] array,
int... values)
Inserts elements into an array at the given index (starting from zero).
|
static long[] |
insert(int index,
long[] array,
long... values)
Inserts elements into an array at the given index (starting from zero).
|
static short[] |
insert(int index,
short[] array,
short... values)
Inserts elements into an array at the given index (starting from zero).
|
static <T> T[] |
insert(int index,
T[] array,
T... values)
Inserts elements into an array at the given index (starting from zero).
|
static <T> Object |
insert(Object array,
int index,
T... newElements)
将新元素插入到到已有数组中的某个位置
添加新元素会生成一个新的数组,不影响原数组 如果插入位置为为负数,从原数组从后向前计数,若大于原数组长度,则空白处用null填充 |
static <T> T[] |
insert(T[] array,
int index,
T... newElements) |
static boolean |
isArray(Object obj)
对象是否为数组对象
|
static <T> boolean |
isArrayIndexValid(T[] array,
int index)
Returns whether a given array can safely be accessed at the given index.
|
static boolean |
isEmpty(boolean[] array)
数组是否为空
|
static boolean |
isEmpty(byte[] array)
数组是否为空
|
static boolean |
isEmpty(char[] array)
数组是否为空
|
static boolean |
isEmpty(double[] array)
数组是否为空
|
static boolean |
isEmpty(float[] array)
数组是否为空
|
static boolean |
isEmpty(int[] array)
数组是否为空
|
static boolean |
isEmpty(long[] array)
数组是否为空
|
static boolean |
isEmpty(Object array)
数组是否为空
此方法会匹配单一对象,如果此对象为 null则返回true如果此对象为非数组,理解为此对象为数组的第一个元素,则返回false 如果此对象为数组对象,数组长度大于0情况下返回false,否则返回true |
static boolean |
isEmpty(Object[] array)
数组是否为空
此方法会匹配单一对象,如果此对象为 null则返回true如果此对象为非数组,理解为此对象为数组的第一个元素,则返回false 如果此对象为数组对象,数组长度大于0情况下返回false,否则返回true |
static boolean |
isEmpty(short[] array)
数组是否为空
|
static boolean |
isNotEmpty(boolean[] array)
数组是否为非空
|
static boolean |
isNotEmpty(byte[] array)
数组是否为非空
|
static boolean |
isNotEmpty(char[] array)
数组是否为非空
|
static boolean |
isNotEmpty(double[] array)
数组是否为非空
|
static boolean |
isNotEmpty(float[] array)
数组是否为非空
|
static boolean |
isNotEmpty(int[] array)
数组是否为非空
|
static boolean |
isNotEmpty(long[] array)
数组是否为非空
|
static boolean |
isNotEmpty(short[] array)
数组是否为非空
|
static <T> boolean |
isNotEmpty(T[] array)
数组是否为非空
此方法会匹配单一对象,如果此对象为 null则返回false如果此对象为非数组,理解为此对象为数组的第一个元素,则返回true 如果此对象为数组对象,数组长度大于0情况下返回true,否则返回false |
static boolean |
isSameLength(boolean[] array1,
boolean[] array2)
检查两个数组是否相同长度
|
static boolean |
isSameLength(byte[] array1,
byte[] array2)
检查两个数组是否相同长度
|
static boolean |
isSameLength(char[] array1,
char[] array2)
检查两个数组是否相同长度
|
static boolean |
isSameLength(double[] array1,
double[] array2)
检查两个数组是否相同长度
|
static boolean |
isSameLength(float[] array1,
float[] array2)
检查两个数组是否相同长度
|
static boolean |
isSameLength(int[] array1,
int[] array2)
检查两个数组是否相同长度
|
static boolean |
isSameLength(long[] array1,
long[] array2)
检查两个数组是否相同长度
|
static boolean |
isSameLength(Object[] array1,
Object[] array2)
检查两个数组是否相同长度
|
static boolean |
isSameLength(short[] array1,
short[] array2)
检查两个数组是否相同长度
|
static boolean |
isSameType(Object array1,
Object array2)
检查两个数组是否为同一类型
|
static boolean |
isSorted(boolean[] array)
This method checks whether the provided array is sorted according to natural ordering
(
false before true). |
static boolean |
isSorted(byte[] array)
This method checks whether the provided array is sorted according to natural ordering.
|
static boolean |
isSorted(char[] array)
This method checks whether the provided array is sorted according to natural ordering.
|
static boolean |
isSorted(double[] array)
This method checks whether the provided array is sorted according to natural ordering.
|
static boolean |
isSorted(float[] array)
This method checks whether the provided array is sorted according to natural ordering.
|
static boolean |
isSorted(int[] array)
This method checks whether the provided array is sorted according to natural ordering.
|
static boolean |
isSorted(long[] array)
This method checks whether the provided array is sorted according to natural ordering.
|
static boolean |
isSorted(short[] array)
This method checks whether the provided array is sorted according to natural ordering.
|
static <T extends Comparable<? super T>> |
isSorted(T[] array)
This method checks whether the provided array is sorted according to the class's
compareTo method. |
static <T> boolean |
isSorted(T[] array,
Comparator<T> comparator)
This method checks whether the provided array is sorted according to the provided
Comparator. |
static String |
join(boolean[] array,
CharSequence conjunction)
以 conjunction 为分隔符将数组转换为字符串
|
static String |
join(byte[] array,
CharSequence conjunction)
以 conjunction 为分隔符将数组转换为字符串
|
static String |
join(char[] array,
CharSequence conjunction)
以 conjunction 为分隔符将数组转换为字符串
|
static String |
join(double[] array,
CharSequence conjunction)
以 conjunction 为分隔符将数组转换为字符串
|
static String |
join(float[] array,
CharSequence conjunction)
以 conjunction 为分隔符将数组转换为字符串
|
static String |
join(int[] array,
CharSequence conjunction)
以 conjunction 为分隔符将数组转换为字符串
|
static String |
join(long[] array,
CharSequence conjunction)
以 conjunction 为分隔符将数组转换为字符串
|
static String |
join(Object array,
CharSequence conjunction)
以 conjunction 为分隔符将数组转换为字符串
|
static String |
join(short[] array,
CharSequence conjunction)
以 conjunction 为分隔符将数组转换为字符串
|
static <T> String |
join(T[] array,
CharSequence conjunction,
String prefix,
String suffix)
以 conjunction 为分隔符将数组转换为字符串
|
static int |
lastIndexOf(boolean[] array,
boolean value)
返回数组中指定元素所在最后的位置,未找到返回
INDEX_NOT_FOUND |
static int |
lastIndexOf(boolean[] array,
boolean value,
int index)
返回数组中指定元素所在最后的位置,未找到返回
INDEX_NOT_FOUND |
static int |
lastIndexOf(byte[] array,
byte value)
返回数组中指定元素所在最后的位置,未找到返回
INDEX_NOT_FOUND |
static int |
lastIndexOf(byte[] array,
byte value,
int index)
返回数组中指定元素所在最后的位置,未找到返回
INDEX_NOT_FOUND |
static int |
lastIndexOf(char[] array,
char value)
返回数组中指定元素所在最后的位置,未找到返回
INDEX_NOT_FOUND |
static int |
lastIndexOf(char[] array,
char value,
int index)
返回数组中指定元素所在最后的位置,未找到返回
INDEX_NOT_FOUND |
static int |
lastIndexOf(double[] array,
double value)
返回数组中指定元素所在最后的位置,未找到返回
INDEX_NOT_FOUND |
static int |
lastIndexOf(double[] array,
double value,
double tolerance)
返回数组中指定元素所在最后的位置,未找到返回
INDEX_NOT_FOUND |
static int |
lastIndexOf(double[] array,
double value,
int index)
返回数组中指定元素所在最后的位置,未找到返回
INDEX_NOT_FOUND |
static int |
lastIndexOf(double[] array,
double value,
int index,
double tolerance)
返回数组中指定元素所在最后的位置,未找到返回
INDEX_NOT_FOUND |
static int |
lastIndexOf(float[] array,
float value)
返回数组中指定元素所在最后的位置,未找到返回
INDEX_NOT_FOUND |
static int |
lastIndexOf(float[] array,
float value,
int index)
返回数组中指定元素所在最后的位置,未找到返回
INDEX_NOT_FOUND |
static int |
lastIndexOf(int[] array,
int value)
返回数组中指定元素所在最后的位置,未找到返回
INDEX_NOT_FOUND |
static int |
lastIndexOf(int[] array,
int value,
int index)
返回数组中指定元素所在最后的位置,未找到返回
INDEX_NOT_FOUND |
static int |
lastIndexOf(long[] array,
long value)
返回数组中指定元素所在最后的位置,未找到返回
INDEX_NOT_FOUND |
static int |
lastIndexOf(long[] array,
long value,
int index)
返回数组中指定元素所在最后的位置,未找到返回
INDEX_NOT_FOUND |
static int |
lastIndexOf(Object[] array,
Object value)
返回数组中指定元素所在最后的位置,未找到返回
INDEX_NOT_FOUND |
static int |
lastIndexOf(Object[] array,
Object value,
int index)
返回数组中指定元素所在最后的位置,未找到返回
INDEX_NOT_FOUND |
static int |
lastIndexOf(short[] array,
short value)
返回数组中指定元素所在最后的位置,未找到返回
INDEX_NOT_FOUND |
static int |
lastIndexOf(short[] array,
short value,
int index)
返回数组中指定元素所在最后的位置,未找到返回
INDEX_NOT_FOUND |
static int |
length(Object array)
获取数组长度
如果参数为 null,返回0 |
static byte |
max(byte... numberArray)
取最大值
|
static char |
max(char... numberArray)
取最大值
|
static double |
max(double... numberArray)
取最大值
|
static float |
max(float... numberArray)
取最大值
|
static int |
max(int... numberArray)
取最大值
|
static long |
max(long... numberArray)
取最大值
|
static short |
max(short... numberArray)
取最大值
|
static <T extends Comparable<? super T>> |
max(T[] numberArray)
取最大值
|
static byte |
min(byte... numberArray)
取最小值
|
static char |
min(char... numberArray)
取最小值
|
static double |
min(double... numberArray)
取最小值
|
static float |
min(float... numberArray)
取最小值
|
static int |
min(int... numberArray)
取最小值
|
static long |
min(long... numberArray)
取最小值
|
static short |
min(short... numberArray)
取最小值
|
static <T extends Comparable<? super T>> |
min(T[] numberArray)
取最小值
|
static <T> T[] |
newArray(Class<?> componentType,
int newSize)
新建一个空数组
|
static <T> T[] |
newArray(int newSize)
新建一个空数组
|
static boolean[] |
nullToEmpty(boolean[] array)
输入数组返回一个空数组或原始数组
|
static Boolean[] |
nullToEmpty(Boolean[] array)
输入数组返回一个空数组或原始数组
|
static byte[] |
nullToEmpty(byte[] array)
输入数组返回一个空数组或原始数组
|
static Byte[] |
nullToEmpty(Byte[] array)
输入数组返回一个空数组或原始数组
|
static char[] |
nullToEmpty(char[] array)
输入数组返回一个空数组或原始数组
|
static Character[] |
nullToEmpty(Character[] array)
输入数组返回一个空数组或原始数组
|
static Class<?>[] |
nullToEmpty(Class<?>[] array)
输入数组返回一个空数组或原始数组
|
static double[] |
nullToEmpty(double[] array)
输入数组返回一个空数组或原始数组
|
static Double[] |
nullToEmpty(Double[] array)
输入数组返回一个空数组或原始数组
|
static float[] |
nullToEmpty(float[] array)
输入数组返回一个空数组或原始数组
|
static Float[] |
nullToEmpty(Float[] array)
输入数组返回一个空数组或原始数组
|
static int[] |
nullToEmpty(int[] array)
输入数组返回一个空数组或原始数组
|
static Integer[] |
nullToEmpty(Integer[] array)
输入数组返回一个空数组或原始数组
|
static long[] |
nullToEmpty(long[] array)
输入数组返回一个空数组或原始数组
|
static Long[] |
nullToEmpty(Long[] array)
输入数组返回一个空数组或原始数组
|
static Object[] |
nullToEmpty(Object[] array)
输入数组返回一个空数组或原始数组
|
static short[] |
nullToEmpty(short[] array)
输入数组返回一个空数组或原始数组
|
static Short[] |
nullToEmpty(Short[] array)
输入数组返回一个空数组或原始数组
|
static String[] |
nullToEmpty(String[] array)
输入数组返回一个空数组或原始数组
|
static <T> T[] |
nullToEmpty(T[] array,
Class<T[]> type)
输入数组返回一个空数组或原始数组
|
static int[] |
range(int excludedEnd)
生成一个从0开始的数字列表
|
static int[] |
range(int includedStart,
int excludedEnd)
生成一个数字列表
自动判定正序反序 |
static int[] |
range(int includedStart,
int excludedEnd,
int step)
生成一个数字列表
自动判定正序反序 |
static boolean[] |
remove(boolean[] array,
int index)
Removes the element at the specified position from the specified array.
|
static byte[] |
remove(byte[] array,
int index)
Removes the element at the specified position from the specified array.
|
static char[] |
remove(char[] array,
int index)
Removes the element at the specified position from the specified array.
|
static double[] |
remove(double[] array,
int index)
Removes the element at the specified position from the specified array.
|
static float[] |
remove(float[] array,
int index)
Removes the element at the specified position from the specified array.
|
static int[] |
remove(int[] array,
int index)
Removes the element at the specified position from the specified array.
|
static long[] |
remove(long[] array,
int index)
Removes the element at the specified position from the specified array.
|
static short[] |
remove(short[] array,
int index)
Removes the element at the specified position from the specified array.
|
static <T> T[] |
remove(T[] array,
int index)
Removes the element at the specified position from the specified array.
|
static boolean[] |
removeAll(boolean[] array,
int... indices)
Removes the elements at the specified positions from the specified array.
|
static byte[] |
removeAll(byte[] array,
int... indices)
Removes the elements at the specified positions from the specified array.
|
static char[] |
removeAll(char[] array,
int... indices)
Removes the elements at the specified positions from the specified array.
|
static double[] |
removeAll(double[] array,
int... indices)
Removes the elements at the specified positions from the specified array.
|
static float[] |
removeAll(float[] array,
int... indices)
Removes the elements at the specified positions from the specified array.
|
static int[] |
removeAll(int[] array,
int... indices)
Removes the elements at the specified positions from the specified array.
|
static long[] |
removeAll(long[] array,
int... indices)
Removes the elements at the specified positions from the specified array.
|
static short[] |
removeAll(short[] array,
int... indices)
Removes the elements at the specified positions from the specified array.
|
static <T> T[] |
removeAll(T[] array,
int... indices)
Removes the elements at the specified positions from the specified array.
|
static boolean[] |
removeAllOccurences(boolean[] array,
boolean element)
Removes the occurrences of the specified element from the specified boolean array.
|
static byte[] |
removeAllOccurences(byte[] array,
byte element)
Removes the occurrences of the specified element from the specified byte array.
|
static char[] |
removeAllOccurences(char[] array,
char element)
Removes the occurrences of the specified element from the specified char array.
|
static double[] |
removeAllOccurences(double[] array,
double element)
Removes the occurrences of the specified element from the specified double array.
|
static float[] |
removeAllOccurences(float[] array,
float element)
Removes the occurrences of the specified element from the specified float array.
|
static int[] |
removeAllOccurences(int[] array,
int element)
Removes the occurrences of the specified element from the specified int array.
|
static long[] |
removeAllOccurences(long[] array,
long element)
Removes the occurrences of the specified element from the specified long array.
|
static short[] |
removeAllOccurences(short[] array,
short element)
Removes the occurrences of the specified element from the specified short array.
|
static <T> T[] |
removeAllOccurences(T[] array,
T element)
Removes the occurrences of the specified element from the specified array.
|
static boolean[] |
removeElement(boolean[] array,
boolean element)
Removes the first occurrence of the specified element from the
specified array.
|
static byte[] |
removeElement(byte[] array,
byte element)
Removes the first occurrence of the specified element from the
specified array.
|
static char[] |
removeElement(char[] array,
char element)
Removes the first occurrence of the specified element from the
specified array.
|
static double[] |
removeElement(double[] array,
double element)
Removes the first occurrence of the specified element from the
specified array.
|
static float[] |
removeElement(float[] array,
float element)
Removes the first occurrence of the specified element from the
specified array.
|
static int[] |
removeElement(int[] array,
int element)
Removes the first occurrence of the specified element from the
specified array.
|
static long[] |
removeElement(long[] array,
long element)
Removes the first occurrence of the specified element from the
specified array.
|
static short[] |
removeElement(short[] array,
short element)
Removes the first occurrence of the specified element from the
specified array.
|
static <T> T[] |
removeElement(T[] array,
Object element)
Removes the first occurrence of the specified element from the
specified array.
|
static boolean[] |
removeElements(boolean[] array,
boolean... values)
Removes occurrences of specified elements, in specified quantities,
from the specified array.
|
static byte[] |
removeElements(byte[] array,
byte... values)
Removes occurrences of specified elements, in specified quantities,
from the specified array.
|
static char[] |
removeElements(char[] array,
char... values)
Removes occurrences of specified elements, in specified quantities,
from the specified array.
|
static double[] |
removeElements(double[] array,
double... values)
Removes occurrences of specified elements, in specified quantities,
from the specified array.
|
static float[] |
removeElements(float[] array,
float... values)
Removes occurrences of specified elements, in specified quantities,
from the specified array.
|
static int[] |
removeElements(int[] array,
int... values)
Removes occurrences of specified elements, in specified quantities,
from the specified array.
|
static long[] |
removeElements(long[] array,
long... values)
Removes occurrences of specified elements, in specified quantities,
from the specified array.
|
static short[] |
removeElements(short[] array,
short... values)
Removes occurrences of specified elements, in specified quantities,
from the specified array.
|
static <T> T[] |
removeElements(T[] array,
T... values)
Removes occurrences of specified elements, in specified quantities,
from the specified array.
|
static <T> T[] |
resize(T[] buffer,
int newSize)
生成一个新的重新设置大小的数组
新数组的类型为原数组的类型,调整大小后拷贝原数组到新数组下。扩大则占位前N个位置,缩小则截断 |
static <T> T[] |
resize(T[] buffer,
int newSize,
Class<?> componentType)
生成一个新的重新设置大小的数组
调整大小后拷贝原数组到新数组下。扩大则占位前N个位置,缩小则截断 |
static void |
reverse(boolean[] array)
反转数组,会变更原数组
|
static void |
reverse(boolean[] array,
int startIndex,
int endIndex) |
static void |
reverse(byte[] array)
反转数组,会变更原数组
|
static void |
reverse(byte[] array,
int startIndex,
int endIndex)
反转数组,会变更原数组
|
static void |
reverse(char[] array)
反转数组,会变更原数组
|
static void |
reverse(char[] array,
int startIndex,
int endIndex)
反转数组,会变更原数组
|
static void |
reverse(double[] array)
反转数组,会变更原数组
|
static void |
reverse(double[] array,
int startIndex,
int endIndex)
反转数组,会变更原数组
|
static void |
reverse(float[] array)
反转数组,会变更原数组
|
static void |
reverse(float[] array,
int startIndex,
int endIndex)
反转数组,会变更原数组
|
static void |
reverse(int[] array)
反转数组,会变更原数组
|
static void |
reverse(int[] array,
int startIndex,
int endIndex)
反转数组,会变更原数组
|
static void |
reverse(long[] array)
反转数组,会变更原数组
|
static void |
reverse(long[] array,
int startIndex,
int endIndex)
反转数组,会变更原数组
|
static void |
reverse(Object[] array)
反转数组,会变更原数组
|
static void |
reverse(Object[] array,
int startIndex,
int endIndex)
反转数组,会变更原数组
|
static void |
reverse(short[] array)
反转数组,会变更原数组
|
static void |
reverse(short[] array,
int startIndex,
int endIndex)
反转数组,会变更原数组
|
static Object |
setOrAppend(Object array,
int index,
Object value)
将元素值设置为数组的某个位置,当给定的index大于数组长度,则追加
|
static <T> T[] |
setOrAppend(T[] buffer,
int index,
T value)
将元素值设置为数组的某个位置,当给定的index大于数组长度,则追加
|
static void |
shift(boolean[] array,
int offset)
改变数组的顺序
|
static void |
shift(boolean[] array,
int startIndex,
int endIndex,
int offset)
改变数组的顺序
|
static void |
shift(byte[] array,
int offset)
改变数组的顺序
|
static void |
shift(byte[] array,
int startIndex,
int endIndex,
int offset)
改变数组的顺序
|
static void |
shift(char[] array,
int offset)
改变数组的顺序
|
static void |
shift(char[] array,
int startIndex,
int endIndex,
int offset)
改变数组的顺序
|
static void |
shift(double[] array,
int offset)
改变数组的顺序
|
static void |
shift(double[] array,
int startIndex,
int endIndex,
int offset)
改变数组的顺序
|
static void |
shift(float[] array,
int offset)
改变数组的顺序
|
static void |
shift(float[] array,
int startIndex,
int endIndex,
int offset)
改变数组的顺序
|
static void |
shift(int[] array,
int offset)
Shifts the order of the given int array.
|
static void |
shift(int[] array,
int startIndex,
int endIndex,
int offset)
改变数组的顺序
|
static void |
shift(long[] array,
int offset)
Shifts the order of the given long array.
|
static void |
shift(long[] array,
int startIndex,
int endIndex,
int offset)
改变数组的顺序
|
static void |
shift(Object[] array,
int offset)
Shifts the order of the given array.
|
static void |
shift(Object[] array,
int startIndex,
int endIndex,
int offset)
改变数组的顺序
|
static void |
shift(short[] array,
int offset)
改变数组的顺序
|
static void |
shift(short[] array,
int startIndex,
int endIndex,
int offset)
改变数组的顺序
|
static void |
shuffle(boolean[] array)
Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
|
static void |
shuffle(boolean[] array,
Random random)
Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
|
static void |
shuffle(byte[] array)
Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
|
static void |
shuffle(byte[] array,
Random random)
Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
|
static void |
shuffle(char[] array)
Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
|
static void |
shuffle(char[] array,
Random random)
Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
|
static void |
shuffle(double[] array)
Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
|
static void |
shuffle(double[] array,
Random random)
Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
|
static void |
shuffle(float[] array)
Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
|
static void |
shuffle(float[] array,
Random random)
Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
|
static void |
shuffle(int[] array)
Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
|
static void |
shuffle(int[] array,
Random random)
Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
|
static void |
shuffle(long[] array)
Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
|
static void |
shuffle(long[] array,
Random random)
Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
|
static void |
shuffle(Object[] array)
Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
|
static void |
shuffle(Object[] array,
Random random)
Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
|
static void |
shuffle(short[] array)
Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
|
static void |
shuffle(short[] array,
Random random)
Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
|
static byte[][] |
split(byte[] array,
int len)
拆分byte数组为几个等份(最后一份可能小于len)
|
static Object[] |
sub(Object array,
int start,
int end)
获取子数组
|
static Object[] |
sub(Object array,
int start,
int end,
int step)
获取子数组
|
static boolean[] |
subarray(boolean[] array,
int startIndex,
int endIndex)
生成一个新的数组,其中包含元素开始索引取值至结束位置索引。
开始索引包含,结束索引不包含,空数组输入产生空输出。
|
static byte[] |
subarray(byte[] array,
int startIndex,
int endIndex)
生成一个新的数组,其中包含元素开始索引取值至结束位置索引。
开始索引包含,结束索引不包含,空数组输入产生空输出。
|
static char[] |
subarray(char[] array,
int startIndex,
int endIndex)
生成一个新的数组,其中包含元素开始索引取值至结束位置索引。
开始索引包含,结束索引不包含,空数组输入产生空输出。
|
static double[] |
subarray(double[] array,
int startIndex,
int endIndex)
生成一个新的数组,其中包含元素开始索引取值至结束位置索引。
开始索引包含,结束索引不包含,空数组输入产生空输出。
|
static float[] |
subarray(float[] array,
int startIndex,
int endIndex)
生成一个新的数组,其中包含元素开始索引取值至结束位置索引。
开始索引包含,结束索引不包含,空数组输入产生空输出。
|
static int[] |
subarray(int[] array,
int startIndex,
int endIndex)
生成一个新的数组,其中包含元素开始索引取值至结束位置索引。
开始索引包含,结束索引不包含,空数组输入产生空输出。
|
static long[] |
subarray(long[] array,
int startIndex,
int endIndex)
生成一个新的数组,其中包含元素开始索引取值至结束位置索引。
开始索引包含,结束索引不包含,空数组输入产生空输出。
|
static short[] |
subarray(short[] array,
int startIndex,
int endIndex)
生成一个新的数组,其中包含元素开始索引取值至结束位置索引。
开始索引包含,结束索引不包含,空数组输入产生空输出。
|
static <T> T[] |
subarray(T[] array,
int startIndex,
int endIndex)
生成一个新的数组,其中包含元素开始索引取值至结束位置索引。
开始索引包含,结束索引不包含,空数组输入产生空输出。
|
static void |
swap(boolean[] array,
int offset1,
int offset2)
交换数组中连个位置的值
|
static void |
swap(boolean[] array,
int offset1,
int offset2,
int len)
交换数组中连个位置的值
|
static void |
swap(byte[] array,
int offset1,
int offset2)
交换数组中连个位置的值
|
static void |
swap(byte[] array,
int offset1,
int offset2,
int len)
交换数组中连个位置的值
|
static void |
swap(char[] array,
int offset1,
int offset2)
交换数组中连个位置的值
|
static void |
swap(char[] array,
int offset1,
int offset2,
int len)
交换数组中连个位置的值
|
static void |
swap(double[] array,
int offset1,
int offset2)
交换数组中连个位置的值
|
static void |
swap(double[] array,
int offset1,
int offset2,
int len)
交换数组中连个位置的值
|
static void |
swap(float[] array,
int offset1,
int offset2)
交换数组中连个位置的值
|
static void |
swap(float[] array,
int offset1,
int offset2,
int len)
交换数组中连个位置的值
|
static void |
swap(int[] array,
int offset1,
int offset2)
交换数组中连个位置的值
|
static void |
swap(int[] array,
int offset1,
int offset2,
int len)
交换数组中连个位置的值
|
static void |
swap(long[] array,
int offset1,
int offset2)
交换数组中连个位置的值
|
static void |
swap(long[] array,
int offset1,
int offset2,
int len)
交换数组中连个位置的值
|
static void |
swap(Object[] array,
int offset1,
int offset2)
交换数组中连个位置的值
|
static void |
swap(Object[] array,
int offset1,
int offset2,
int len)
交换数组中连个位置的值
|
static void |
swap(short[] array,
int offset1,
int offset2)
交换数组中连个位置的值
|
static void |
swap(short[] array,
int offset1,
int offset2,
int len)
交换数组中连个位置的值
|
static byte[] |
toArray(ByteBuffer bytebuffer)
ByteBuffer 转byte数组 |
static <T> T[] |
toArray(Collection<T> collection,
Class<T> componentType)
将集合转为数组
|
static <T> T[] |
toArray(T... items)
该方法通常用于调用者本身使用泛型类型的场景
必须组合成数组。
|
static Map<Object,Object> |
toMap(Object[] array)
|
static Boolean[] |
toObject(boolean[] array)
Converts an array of primitive booleans to objects.
|
static Byte[] |
toObject(byte[] array)
Converts an array of primitive bytes to objects.
|
static Character[] |
toObject(char[] array)
Converts an array of primitive chars to objects.
|
static Double[] |
toObject(double[] array)
Converts an array of primitive doubles to objects.
|
static Float[] |
toObject(float[] array)
Converts an array of primitive floats to objects.
|
static Integer[] |
toObject(int[] array)
Converts an array of primitive ints to objects.
|
static Long[] |
toObject(long[] array)
Converts an array of primitive longs to objects.
|
static Short[] |
toObject(short[] array)
Converts an array of primitive shorts to objects.
|
static boolean[] |
toPrimitive(Boolean[] array)
Converts an array of object Booleans to primitives.
|
static boolean[] |
toPrimitive(Boolean[] array,
boolean valueForNull)
Converts an array of object Booleans to primitives handling
null. |
static byte[] |
toPrimitive(Byte[] array)
Converts an array of object Bytes to primitives.
|
static byte[] |
toPrimitive(Byte[] array,
byte valueForNull)
Converts an array of object Bytes to primitives handling
null. |
static char[] |
toPrimitive(Character[] array)
Converts an array of object Characters to primitives.
|
static char[] |
toPrimitive(Character[] array,
char valueForNull)
Converts an array of object Character to primitives handling
null. |
static double[] |
toPrimitive(Double[] array)
Converts an array of object Doubles to primitives.
|
static double[] |
toPrimitive(Double[] array,
double valueForNull)
Converts an array of object Doubles to primitives handling
null. |
static float[] |
toPrimitive(Float[] array)
Converts an array of object Floats to primitives.
|
static float[] |
toPrimitive(Float[] array,
float valueForNull)
Converts an array of object Floats to primitives handling
null. |
static int[] |
toPrimitive(Integer[] array)
Converts an array of object Integers to primitives.
|
static int[] |
toPrimitive(Integer[] array,
int valueForNull)
Converts an array of object Integer to primitives handling
null. |
static long[] |
toPrimitive(Long[] array)
Converts an array of object Longs to primitives.
|
static long[] |
toPrimitive(Long[] array,
long valueForNull)
Converts an array of object Long to primitives handling
null. |
static Object |
toPrimitive(Object array)
Create an array of primitive type from an array of wrapper types.
|
static short[] |
toPrimitive(Short[] array)
Converts an array of object Shorts to primitives.
|
static short[] |
toPrimitive(Short[] array,
short valueForNull)
Converts an array of object Short to primitives handling
null. |
static String |
toString(Object array)
数组或集合转String
|
static String |
toString(Object array,
String stringIfNull)
数组或集合转String
|
static String[] |
toStringArray(Object[] array)
Returns an array containing the string representation of each element in the argument array.
|
static String[] |
toStringArray(Object[] array,
String valueForNullElements)
Returns an array containing the string representation of each element in the argument
array handling
null elements. |
static boolean[] |
unWrap(Boolean... values)
包装类数组转为原始类型数组
|
static byte[] |
unWrap(Byte... values)
包装类数组转为原始类型数组
|
static char[] |
unWrap(Character... values)
包装类数组转为原始类型数组
|
static double[] |
unWrap(Double... values)
包装类数组转为原始类型数组
|
static float[] |
unWrap(Float... values)
包装类数组转为原始类型数组
|
static int[] |
unWrap(Integer... values)
包装类数组转为原始类型数组
|
static long[] |
unWrap(Long... values)
包装类数组转为原始类型数组
|
static short[] |
unWrap(Short... values)
包装类数组转为原始类型数组
|
static Boolean[] |
wrap(boolean... values)
将原始类型数组包装为包装类型
|
static Byte[] |
wrap(byte... values)
将原始类型数组包装为包装类型
|
static Character[] |
wrap(char... values)
将原始类型数组包装为包装类型
|
static Double[] |
wrap(double... values)
将原始类型数组包装为包装类型
|
static Float[] |
wrap(float... values)
将原始类型数组包装为包装类型
|
static Long[] |
wrap(long... values)
将原始类型数组包装为包装类型
|
static Object[] |
wrap(Object obj)
包装数组对象
|
static Short[] |
wrap(short... values)
将原始类型数组包装为包装类型
|
static <K,V> Map<K,V> |
zip(K[] keys,
V[] values,
boolean isOrder)
映射键值(参考Python的zip()函数)
例如: keys = [a,b,c,d] values = [1,2,3,4] 则得到的Map是 {a=1, b=2, c=3, d=4} 如果两个数组长度不同,则只对应最短部分 |
public static final Object[] EMPTY_OBJECT_ARRAY
Object array.public static final Class<?>[] EMPTY_CLASS_ARRAY
Class array.public static final String[] EMPTY_STRING_ARRAY
String array.public static final long[] EMPTY_LONG_ARRAY
long array.public static final Long[] EMPTY_LONG_OBJECT_ARRAY
Long array.public static final int[] EMPTY_INT_ARRAY
int array.public static final Integer[] EMPTY_INTEGER_OBJECT_ARRAY
Integer array.public static final short[] EMPTY_SHORT_ARRAY
short array.public static final Short[] EMPTY_SHORT_OBJECT_ARRAY
Short array.public static final byte[] EMPTY_BYTE_ARRAY
byte array.public static final Byte[] EMPTY_BYTE_OBJECT_ARRAY
Byte array.public static final double[] EMPTY_DOUBLE_ARRAY
double array.public static final Double[] EMPTY_DOUBLE_OBJECT_ARRAY
Double array.public static final float[] EMPTY_FLOAT_ARRAY
float array.public static final Float[] EMPTY_FLOAT_OBJECT_ARRAY
Float array.public static final boolean[] EMPTY_BOOLEAN_ARRAY
boolean array.public static final Boolean[] EMPTY_BOOLEAN_OBJECT_ARRAY
Boolean array.public static final char[] EMPTY_CHAR_ARRAY
char array.public static final Character[] EMPTY_CHARACTER_OBJECT_ARRAY
Character array.public static final int INDEX_NOT_FOUND
-1.
此值由该类中的方法返回,也可用于与所返回的值进行比较List.public static String toString(Object array)
array - 集合或数组对象public static String toString(Object array, String stringIfNull)
array - 集合或数组对象stringIfNull - 是否nullpublic static int hashCode(Object array)
array - 数组public static Map<Object,Object> toMap(Object[] array)
Map
数组的每个元素必须是Map。或数组,其中至少包含两个
元素,其中第一个元素用作键,第二个元素用作值。
Map colorMap = ArrayUtils.toMap(new String[][] {
{"RED", "#FF0000"},
{"GREEN", "#00FF00"},
{"BLUE", "#0000FF"}});
array - 数组Mappublic static <T> T[] toArray(T... items)
注意,此方法只适用于提供相同类型的参数,以便
编译器可以推断数组本身的类型。虽然可以选择
显式输入like in
Number[] array = ArrayUtils.toArray(Integer.valueOf(42),Double.valueOf(Math.PI))
与……相比没有什么真正的优势
new Number[]{整数.valueof(42),Double.valueOf(Math.PI)}。
T - 对象items - 数组public static <T> T[] clone(T[] array)
T - 对象array - 被克隆的数组public static <T> T clone(T obj)
T - 数组元素类型obj - 数组对象public static long[] clone(long[] array)
array - 被克隆的数组public static int[] clone(int[] array)
array - 被克隆的数组public static short[] clone(short[] array)
array - 被克隆的数组public static char[] clone(char[] array)
array - 被克隆的数组public static byte[] clone(byte[] array)
array - 被克隆的数组public static double[] clone(double[] array)
array - 被克隆的数组public static float[] clone(float[] array)
array - 被克隆的数组public static boolean[] clone(boolean[] array)
array - 被克隆的数组public static <T> T[] nullToEmpty(T[] array,
Class<T[]> type)
T - the class typearray - the array to check for null or emptytype - the class representation of the desired arraypublic static empty array if nullIllegalArgumentException - if the type argument is nullpublic static Object[] nullToEmpty(Object[] array)
array - 数组public static Class<?>[] nullToEmpty(Class<?>[] array)
array - 数组public static String[] nullToEmpty(String[] array)
array - 数组public static long[] nullToEmpty(long[] array)
array - 数组public static int[] nullToEmpty(int[] array)
array - 数组public static short[] nullToEmpty(short[] array)
array - 数组public static char[] nullToEmpty(char[] array)
array - 数组public static byte[] nullToEmpty(byte[] array)
array - 数组public static double[] nullToEmpty(double[] array)
array - 数组public static float[] nullToEmpty(float[] array)
array - 数组public static boolean[] nullToEmpty(boolean[] array)
array - 数组public static Long[] nullToEmpty(Long[] array)
array - 数组public static Integer[] nullToEmpty(Integer[] array)
array - 数组public static Short[] nullToEmpty(Short[] array)
array - 数组public static Character[] nullToEmpty(Character[] array)
array - 数组public static Byte[] nullToEmpty(Byte[] array)
array - 数组public static Double[] nullToEmpty(Double[] array)
array - 数组public static Float[] nullToEmpty(Float[] array)
array - 数组public static Boolean[] nullToEmpty(Boolean[] array)
array - 数组public static <T> T[] subarray(T[] array,
int startIndex,
int endIndex)
T - 对象array - 对象数组startIndex - 开始索引endIndex - 结束索引public static long[] subarray(long[] array,
int startIndex,
int endIndex)
array - 对象数组startIndex - 开始索引endIndex - 结束索引public static int[] subarray(int[] array,
int startIndex,
int endIndex)
array - 对象数组startIndex - 开始索引endIndex - 结束索引public static short[] subarray(short[] array,
int startIndex,
int endIndex)
array - 对象数组startIndex - 开始索引endIndex - 结束索引public static char[] subarray(char[] array,
int startIndex,
int endIndex)
array - 对象数组startIndex - 开始索引endIndex - 结束索引public static byte[] subarray(byte[] array,
int startIndex,
int endIndex)
array - 对象数组startIndex - 开始索引endIndex - 结束索引public static double[] subarray(double[] array,
int startIndex,
int endIndex)
array - 对象数组startIndex - 开始索引endIndex - 结束索引public static float[] subarray(float[] array,
int startIndex,
int endIndex)
array - 对象数组startIndex - 开始索引endIndex - 结束索引public static boolean[] subarray(boolean[] array,
int startIndex,
int endIndex)
array - 对象数组startIndex - 开始索引endIndex - 结束索引public static boolean isSameLength(Object[] array1, Object[] array2)
array1 - 参数1array2 - 参数2public static boolean isSameLength(long[] array1,
long[] array2)
array1 - 参数1array2 - 参数2public static boolean isSameLength(int[] array1,
int[] array2)
array1 - 参数1array2 - 参数2public static boolean isSameLength(short[] array1,
short[] array2)
array1 - 参数1array2 - 参数2public static boolean isSameLength(char[] array1,
char[] array2)
array1 - 参数1array2 - 参数2public static boolean isSameLength(byte[] array1,
byte[] array2)
array1 - 参数1array2 - 参数2public static boolean isSameLength(double[] array1,
double[] array2)
array1 - 参数1array2 - 参数2public static boolean isSameLength(float[] array1,
float[] array2)
array1 - 参数1array2 - 参数2public static boolean isSameLength(boolean[] array1,
boolean[] array2)
array1 - 参数1array2 - 参数2public static int getLength(Object array)
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 argument is not an array.public static boolean isSameType(Object array1, Object array2)
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 static void reverse(Object[] array)
array - 数组,会变更public static void reverse(long[] array)
array - 数组,会变更public static void reverse(int[] array)
array - 数组,会变更public static void reverse(short[] array)
array - 数组,会变更public static void reverse(char[] array)
array - 数组,会变更public static void reverse(byte[] array)
array - 数组,会变更public static void reverse(double[] array)
array - 数组,会变更public static void reverse(float[] array)
array - 数组,会变更public static void reverse(boolean[] array)
array - 数组,会变更public static void reverse(boolean[] array,
int startIndex,
int endIndex)
array - 数组,会变更startIndex - 其实位置(包含)endIndex - 结束位置(不包含)public static void reverse(byte[] array,
int startIndex,
int endIndex)
array - 数组,会变更startIndex - 其实位置(包含)endIndex - 结束位置(不包含)public static void reverse(char[] array,
int startIndex,
int endIndex)
array - 数组,会变更startIndex - 其实位置(包含)endIndex - 结束位置(不包含)public static void reverse(double[] array,
int startIndex,
int endIndex)
array - 数组,会变更startIndex - 其实位置(包含)endIndex - 结束位置(不包含)public static void reverse(float[] array,
int startIndex,
int endIndex)
array - 数组,会变更startIndex - 其实位置(包含)endIndex - 结束位置(不包含)public static void reverse(int[] array,
int startIndex,
int endIndex)
array - 数组,会变更startIndex - 其实位置(包含)endIndex - 结束位置(不包含)public static void reverse(long[] array,
int startIndex,
int endIndex)
array - 数组,会变更startIndex - 其实位置(包含)endIndex - 结束位置(不包含)public static void reverse(Object[] array, int startIndex, int endIndex)
array - 数组,会变更startIndex - 其实位置(包含)endIndex - 结束位置(不包含)public static void reverse(short[] array,
int startIndex,
int endIndex)
array - 数组,会变更startIndex - 其实位置(包含)endIndex - 结束位置(不包含)public static void swap(Object[] array, int offset1, int offset2)
array - 数组offset1 - 位置1offset2 - 位置2
Examples:
public static void swap(long[] array,
int offset1,
int offset2)
array - 数组offset1 - 位置1offset2 - 位置2
Examples:
public static void swap(int[] array,
int offset1,
int offset2)
array - 数组offset1 - 位置1offset2 - 位置2
Examples:
public static void swap(short[] array,
int offset1,
int offset2)
array - 数组offset1 - 位置1offset2 - 位置2
Examples:
public static void swap(char[] array,
int offset1,
int offset2)
array - 数组offset1 - 位置1offset2 - 位置2
Examples:
public static void swap(byte[] array,
int offset1,
int offset2)
array - 数组offset1 - 位置1offset2 - 位置2
Examples:
public static void swap(double[] array,
int offset1,
int offset2)
array - 数组offset1 - 位置1offset2 - 位置2
Examples:
public static void swap(float[] array,
int offset1,
int offset2)
array - 数组offset1 - 位置1offset2 - 位置2
Examples:
public static void swap(boolean[] array,
int offset1,
int offset2)
array - 数组offset1 - 位置1offset2 - 位置2
Examples:
public static void swap(boolean[] array,
int offset1,
int offset2,
int len)
array - 数组offset1 - 位置1offset2 - 位置2len - 从给定索引开始交换的元素数量
Examples:
public static void swap(byte[] array,
int offset1,
int offset2,
int len)
array - 数组offset1 - 位置1offset2 - 位置2len - 从给定索引开始交换的元素数量
Examples:
public static void swap(char[] array,
int offset1,
int offset2,
int len)
array - 数组offset1 - 位置1offset2 - 位置2len - 从给定索引开始交换的元素数量
Examples:
public static void swap(double[] array,
int offset1,
int offset2,
int len)
array - 数组offset1 - 位置1offset2 - 位置2len - 从给定索引开始交换的元素数量
Examples:
public static void swap(float[] array,
int offset1,
int offset2,
int len)
array - 数组offset1 - 位置1offset2 - 位置2len - 从给定索引开始交换的元素数量
Examples:
public static void swap(int[] array,
int offset1,
int offset2,
int len)
array - 数组offset1 - 位置1offset2 - 位置2len - 从给定索引开始交换的元素数量
Examples:
public static void swap(long[] array,
int offset1,
int offset2,
int len)
array - 数组offset1 - 位置1offset2 - 位置2len - 从给定索引开始交换的元素数量
Examples:
public static void swap(Object[] array, int offset1, int offset2, int len)
array - 数组offset1 - 位置1offset2 - 位置2len - 从给定索引开始交换的元素数量
Examples:
public static void swap(short[] array,
int offset1,
int offset2,
int len)
array - 数组offset1 - 位置1offset2 - 位置2len - 从给定索引开始交换的元素数量
Examples:
public static void shift(Object[] array, int offset)
There is no special handling for multi-dimensional arrays. This method
does nothing for null or empty input arrays.
array - the array to shift, may be nulloffset - The number of positions to rotate the elements. If the offset is larger than the number of elements to
rotate, than the effective offset is modulo the number of elements to rotate.public static void shift(long[] array,
int offset)
There is no special handling for multi-dimensional arrays. This method
does nothing for null or empty input arrays.
array - the array to shift, may be nulloffset - The number of positions to rotate the elements. If the offset is larger than the number of elements to
rotate, than the effective offset is modulo the number of elements to rotate.public static void shift(int[] array,
int offset)
There is no special handling for multi-dimensional arrays. This method
does nothing for null or empty input arrays.
array - the array to shift, may be nulloffset - The number of positions to rotate the elements. If the offset is larger than the number of elements to
rotate, than the effective offset is modulo the number of elements to rotate.public static void shift(short[] array,
int offset)
array - 原数组offset - 偏移量public static void shift(char[] array,
int offset)
array - 原数组offset - 偏移量public static void shift(byte[] array,
int offset)
array - 原数组offset - 偏移量public static void shift(double[] array,
int offset)
array - 原数组offset - 偏移量public static void shift(float[] array,
int offset)
array - 原数组offset - 偏移量public static void shift(boolean[] array,
int offset)
array - 原数组offset - 偏移量public static void shift(boolean[] array,
int startIndex,
int endIndex,
int offset)
array - 原数组startIndex - 开始索引endIndex - 结束索引offset - 偏移量public static void shift(byte[] array,
int startIndex,
int endIndex,
int offset)
array - 原数组startIndex - 开始索引endIndex - 结束索引offset - 偏移量public static void shift(char[] array,
int startIndex,
int endIndex,
int offset)
array - 原数组startIndex - 开始索引endIndex - 结束索引offset - 偏移量public static void shift(double[] array,
int startIndex,
int endIndex,
int offset)
array - 原数组startIndex - 开始索引endIndex - 结束索引offset - 偏移量public static void shift(float[] array,
int startIndex,
int endIndex,
int offset)
array - 原数组startIndex - 开始索引endIndex - 结束索引offset - 偏移量public static void shift(int[] array,
int startIndex,
int endIndex,
int offset)
array - 原数组startIndex - 开始索引endIndex - 结束索引offset - 偏移量public static void shift(long[] array,
int startIndex,
int endIndex,
int offset)
array - 原数组startIndex - 开始索引endIndex - 结束索引offset - 偏移量public static void shift(Object[] array, int startIndex, int endIndex, int offset)
array - 原数组startIndex - 开始索引endIndex - 结束索引offset - 偏移量public static void shift(short[] array,
int startIndex,
int endIndex,
int offset)
array - 原数组startIndex - 开始索引endIndex - 结束索引offset - 偏移量public static int indexOf(Object[] array, Object value)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素INDEX_NOT_FOUNDpublic static int indexOf(Object[] array, Object value, int index)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素index - 索引INDEX_NOT_FOUNDpublic static int lastIndexOf(Object[] array, Object value)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素INDEX_NOT_FOUNDpublic static int lastIndexOf(Object[] array, Object value, int index)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素index - 索引INDEX_NOT_FOUNDpublic static boolean contains(Object[] array, Object value)
array - 数组value - 被检查的元素public static int indexOf(long[] array,
long value)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素INDEX_NOT_FOUNDpublic static int indexOf(long[] array,
long value,
int index)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素index - 索引INDEX_NOT_FOUNDpublic static int lastIndexOf(long[] array,
long value)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素INDEX_NOT_FOUNDpublic static int lastIndexOf(long[] array,
long value,
int index)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素index - 索引INDEX_NOT_FOUNDpublic static boolean contains(long[] array,
long value)
array - 数组value - 被检查的元素public static int indexOf(int[] array,
int value)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素INDEX_NOT_FOUNDpublic static int indexOf(int[] array,
int value,
int index)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素index - 索引INDEX_NOT_FOUNDpublic static int lastIndexOf(int[] array,
int value)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素INDEX_NOT_FOUNDpublic static int lastIndexOf(int[] array,
int value,
int index)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素index - 索引INDEX_NOT_FOUNDpublic static boolean contains(int[] array,
int value)
array - 数组value - 被检查的元素public static int indexOf(short[] array,
short value)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素INDEX_NOT_FOUNDpublic static int indexOf(short[] array,
short value,
int index)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素index - 索引INDEX_NOT_FOUNDpublic static int lastIndexOf(short[] array,
short value)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素INDEX_NOT_FOUNDpublic static int lastIndexOf(short[] array,
short value,
int index)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素index - 索引INDEX_NOT_FOUNDpublic static boolean contains(short[] array,
short value)
array - 数组value - 被检查的元素public static int indexOf(char[] array,
char value)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素INDEX_NOT_FOUNDpublic static int indexOf(char[] array,
char value,
int index)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素index - 索引INDEX_NOT_FOUNDpublic static int lastIndexOf(char[] array,
char value)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素INDEX_NOT_FOUNDpublic static int lastIndexOf(char[] array,
char value,
int index)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素index - 索引INDEX_NOT_FOUNDpublic static boolean contains(char[] array,
char value)
array - 数组value - 被检查的元素public static int indexOf(byte[] array,
byte value)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素INDEX_NOT_FOUNDpublic static int indexOf(byte[] array,
byte value,
int index)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素index - 索引INDEX_NOT_FOUNDpublic static int lastIndexOf(byte[] array,
byte value)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素INDEX_NOT_FOUNDpublic static int lastIndexOf(byte[] array,
byte value,
int index)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素index - 索引INDEX_NOT_FOUNDpublic static boolean contains(byte[] array,
byte value)
array - 数组value - 被检查的元素public static int indexOf(double[] array,
double value)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素INDEX_NOT_FOUNDpublic static int indexOf(double[] array,
double value,
double tolerance)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素tolerance - 容差INDEX_NOT_FOUNDpublic static int indexOf(double[] array,
double value,
int index)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素index - 索引INDEX_NOT_FOUNDpublic static int indexOf(double[] array,
double value,
int index,
double tolerance)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素index - 索引tolerance - 容差INDEX_NOT_FOUNDpublic static int lastIndexOf(double[] array,
double value)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素INDEX_NOT_FOUNDpublic static int lastIndexOf(double[] array,
double value,
double tolerance)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素tolerance - 容差INDEX_NOT_FOUNDpublic static int lastIndexOf(double[] array,
double value,
int index)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素index - 索引INDEX_NOT_FOUNDpublic static int lastIndexOf(double[] array,
double value,
int index,
double tolerance)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素index - 索引tolerance - 容差INDEX_NOT_FOUNDpublic static boolean contains(double[] array,
double value)
array - 数组value - 被检查的元素public static boolean contains(double[] array,
double value,
double tolerance)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素tolerance - 容差INDEX_NOT_FOUNDpublic static int indexOf(float[] array,
float value)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素INDEX_NOT_FOUNDpublic static int indexOf(float[] array,
float value,
int index)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素index - 索引INDEX_NOT_FOUNDpublic static int lastIndexOf(float[] array,
float value)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素INDEX_NOT_FOUNDpublic static int lastIndexOf(float[] array,
float value,
int index)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素index - 索引INDEX_NOT_FOUNDpublic static boolean contains(float[] array,
float value)
array - 数组value - 被检查的元素public static int indexOf(boolean[] array,
boolean value)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素INDEX_NOT_FOUNDpublic static int indexOf(boolean[] array,
boolean value,
int index)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素index - 索引INDEX_NOT_FOUNDpublic static int lastIndexOf(boolean[] array,
boolean value)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素INDEX_NOT_FOUNDpublic static int lastIndexOf(boolean[] array,
boolean value,
int index)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素index - 索引INDEX_NOT_FOUNDpublic static boolean contains(boolean[] array,
boolean value)
array - 数组value - 被检查的元素public static 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 static 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 static 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 static 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 inputpublic static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static Object toPrimitive(Object array)
Create an array of primitive type from an array of wrapper types.
This method returns null for a null input array.
array - an array of wrapper objectpublic static 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 static 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 static 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 static boolean isEmpty(Object array)
null则返回truearray - 数组public static boolean isEmpty(Object[] array)
null则返回truearray - 数组public static boolean isEmpty(long[] array)
array - 数组public static boolean isEmpty(int[] array)
array - 数组public static boolean isEmpty(short[] array)
array - 数组public static boolean isEmpty(char[] array)
array - 数组public static boolean isEmpty(byte[] array)
array - 数组public static boolean isEmpty(double[] array)
array - 数组public static boolean isEmpty(float[] array)
array - 数组public static boolean isEmpty(boolean[] array)
array - 数组public static <T> boolean isNotEmpty(T[] array)
null则返回falseT - 对象array - 数组public static boolean isNotEmpty(long[] array)
array - 数组public static boolean isNotEmpty(int[] array)
array - 数组public static boolean isNotEmpty(short[] array)
array - 数组public static boolean isNotEmpty(char[] array)
array - 数组public static boolean isNotEmpty(byte[] array)
array - 数组public static boolean isNotEmpty(double[] array)
array - 数组public static boolean isNotEmpty(float[] array)
array - 数组public static boolean isNotEmpty(boolean[] array)
array - 数组public static <T> T[] addAll(T[] array1,
T... 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"]
T - the component type of the arrayarray1 - 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static <T> T[] add(T[] array,
T 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) = IllegalArgumentException 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"]
T - the component type of the arrayarray - the array to "add" the element to, may be nullelement - the object to add, may be nullIllegalArgumentException - if both arguments are nullpublic static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static <T> T[] add(T[] array,
int index,
T 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) = IllegalArgumentException 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"]
T - the component type of the arrayarray - 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).IllegalArgumentException - if both array and element are null
may be removed in a future release. Please note the handling of null input arrays differs
in the new method: inserting X into a null array results in null not X.public static boolean[] add(boolean[] array,
int index,
boolean 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, true) = [true] ArrayUtils.add([true], 0, false) = [false, true] ArrayUtils.add([false], 1, true) = [false, true] ArrayUtils.add([true, false], 1, true) = [true, true, false]
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).
may be removed in a future release. Please note the handling of null input arrays differs
in the new method: inserting X into a null array results in null not X.public static 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 static 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 static 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 static 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 static 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 static 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 static 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 static <T> T[] remove(T[] array,
int index)
Removes the element at the specified position from the specified array. All subsequent elements are shifted to the left (subtracts 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"]
T - the component type of the arrayarray - 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 static <T> T[] removeElement(T[] array,
Object element)
Removes the first occurrence of the specified element from the specified array. All subsequent elements are shifted to the left (subtracts 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"]
T - the component type of the arrayarray - the array to remove the element from, may be nullelement - the element to be removedpublic static 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 (subtracts 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 static 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 (subtracts 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 static 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 (subtracts 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 static 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 (subtracts 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 static 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 (subtracts 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 static 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 (subtracts 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 static 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 (subtracts 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 static 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 (subtracts 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 static 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 (subtracts 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 static 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 (subtracts 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 static 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 (subtracts 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 static 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 (subtracts 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 static 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 (subtracts 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 static 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 (subtracts 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 static 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 (subtracts 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 static 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 (subtracts 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 static <T> T[] removeAll(T[] array,
int... indices)
Removes the elements at the specified positions from the specified array. All remaining elements are shifted to the left.
This method returns a new array with the same elements of the input array except those at the specified positions. 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.removeAll(["a", "b", "c"], 0, 2) = ["b"] ArrayUtils.removeAll(["a", "b", "c"], 1, 2) = ["a"]
T - the component type of the arrayarray - the array to remove the element from, may not be nullindices - the positions of the elements to be removedIndexOutOfBoundsException - if any index is out of range
(index < 0 || index >= array.length), or if the array is null.public static <T> T[] removeElements(T[] array,
T... values)
Removes occurrences of specified elements, in specified quantities, from the specified array. All subsequent elements are shifted left. For any element-to-be-removed specified in greater quantities than contained in the original array, no change occurs beyond the removal of the existing matching items.
This method returns a new array with the same elements of the input array except for the earliest-encountered occurrences of the specified elements. The component type of the returned array is always the same as that of the input array.
ArrayUtils.removeElements(null, "a", "b") = null ArrayUtils.removeElements([], "a", "b") = [] ArrayUtils.removeElements(["a"], "b", "c") = ["a"] ArrayUtils.removeElements(["a", "b"], "a", "c") = ["b"] ArrayUtils.removeElements(["a", "b", "a"], "a") = ["b", "a"] ArrayUtils.removeElements(["a", "b", "a"], "a", "a") = ["b"]
T - the component type of the arrayarray - the array to remove the element from, may be nullvalues - the elements to be removedpublic static byte[] removeAll(byte[] array,
int... indices)
Removes the elements at the specified positions from the specified array. All remaining elements are shifted to the left.
This method returns a new array with the same elements of the input array except those at the specified positions. 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.removeAll([1], 0) = [] ArrayUtils.removeAll([2, 6], 0) = [6] ArrayUtils.removeAll([2, 6], 0, 1) = [] ArrayUtils.removeAll([2, 6, 3], 1, 2) = [2] ArrayUtils.removeAll([2, 6, 3], 0, 2) = [6] ArrayUtils.removeAll([2, 6, 3], 0, 1, 2) = []
array - the array to remove the element from, may not be nullindices - the positions of the elements to be removedIndexOutOfBoundsException - if any index is out of range
(index < 0 || index >= array.length), or if the array is null.public static byte[] removeElements(byte[] array,
byte... values)
Removes occurrences of specified elements, in specified quantities, from the specified array. All subsequent elements are shifted left. For any element-to-be-removed specified in greater quantities than contained in the original array, no change occurs beyond the removal of the existing matching items.
This method returns a new array with the same elements of the input array except for the earliest-encountered occurrences of the specified elements. The component type of the returned array is always the same as that of the input array.
ArrayUtils.removeElements(null, 1, 2) = null ArrayUtils.removeElements([], 1, 2) = [] ArrayUtils.removeElements([1], 2, 3) = [1] ArrayUtils.removeElements([1, 3], 1, 2) = [3] ArrayUtils.removeElements([1, 3, 1], 1) = [3, 1] ArrayUtils.removeElements([1, 3, 1], 1, 1) = [3]
array - the array to remove the element from, may be nullvalues - the elements to be removedpublic static short[] removeAll(short[] array,
int... indices)
Removes the elements at the specified positions from the specified array. All remaining elements are shifted to the left.
This method returns a new array with the same elements of the input array except those at the specified positions. 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.removeAll([1], 0) = [] ArrayUtils.removeAll([2, 6], 0) = [6] ArrayUtils.removeAll([2, 6], 0, 1) = [] ArrayUtils.removeAll([2, 6, 3], 1, 2) = [2] ArrayUtils.removeAll([2, 6, 3], 0, 2) = [6] ArrayUtils.removeAll([2, 6, 3], 0, 1, 2) = []
array - the array to remove the element from, may not be nullindices - the positions of the elements to be removedIndexOutOfBoundsException - if any index is out of range
(index < 0 || index >= array.length), or if the array is null.public static short[] removeElements(short[] array,
short... values)
Removes occurrences of specified elements, in specified quantities, from the specified array. All subsequent elements are shifted left. For any element-to-be-removed specified in greater quantities than contained in the original array, no change occurs beyond the removal of the existing matching items.
This method returns a new array with the same elements of the input array except for the earliest-encountered occurrences of the specified elements. The component type of the returned array is always the same as that of the input array.
ArrayUtils.removeElements(null, 1, 2) = null ArrayUtils.removeElements([], 1, 2) = [] ArrayUtils.removeElements([1], 2, 3) = [1] ArrayUtils.removeElements([1, 3], 1, 2) = [3] ArrayUtils.removeElements([1, 3, 1], 1) = [3, 1] ArrayUtils.removeElements([1, 3, 1], 1, 1) = [3]
array - the array to remove the element from, may be nullvalues - the elements to be removedpublic static int[] removeAll(int[] array,
int... indices)
Removes the elements at the specified positions from the specified array. All remaining elements are shifted to the left.
This method returns a new array with the same elements of the input array except those at the specified positions. 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.removeAll([1], 0) = [] ArrayUtils.removeAll([2, 6], 0) = [6] ArrayUtils.removeAll([2, 6], 0, 1) = [] ArrayUtils.removeAll([2, 6, 3], 1, 2) = [2] ArrayUtils.removeAll([2, 6, 3], 0, 2) = [6] ArrayUtils.removeAll([2, 6, 3], 0, 1, 2) = []
array - the array to remove the element from, may not be nullindices - the positions of the elements to be removedIndexOutOfBoundsException - if any index is out of range
(index < 0 || index >= array.length), or if the array is null.public static int[] removeElements(int[] array,
int... values)
Removes occurrences of specified elements, in specified quantities, from the specified array. All subsequent elements are shifted left. For any element-to-be-removed specified in greater quantities than contained in the original array, no change occurs beyond the removal of the existing matching items.
This method returns a new array with the same elements of the input array except for the earliest-encountered occurrences of the specified elements. The component type of the returned array is always the same as that of the input array.
ArrayUtils.removeElements(null, 1, 2) = null ArrayUtils.removeElements([], 1, 2) = [] ArrayUtils.removeElements([1], 2, 3) = [1] ArrayUtils.removeElements([1, 3], 1, 2) = [3] ArrayUtils.removeElements([1, 3, 1], 1) = [3, 1] ArrayUtils.removeElements([1, 3, 1], 1, 1) = [3]
array - the array to remove the element from, may be nullvalues - the elements to be removedpublic static char[] removeAll(char[] array,
int... indices)
Removes the elements at the specified positions from the specified array. All remaining elements are shifted to the left.
This method returns a new array with the same elements of the input array except those at the specified positions. 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.removeAll([1], 0) = [] ArrayUtils.removeAll([2, 6], 0) = [6] ArrayUtils.removeAll([2, 6], 0, 1) = [] ArrayUtils.removeAll([2, 6, 3], 1, 2) = [2] ArrayUtils.removeAll([2, 6, 3], 0, 2) = [6] ArrayUtils.removeAll([2, 6, 3], 0, 1, 2) = []
array - the array to remove the element from, may not be nullindices - the positions of the elements to be removedIndexOutOfBoundsException - if any index is out of range
(index < 0 || index >= array.length), or if the array is null.public static char[] removeElements(char[] array,
char... values)
Removes occurrences of specified elements, in specified quantities, from the specified array. All subsequent elements are shifted left. For any element-to-be-removed specified in greater quantities than contained in the original array, no change occurs beyond the removal of the existing matching items.
This method returns a new array with the same elements of the input array except for the earliest-encountered occurrences of the specified elements. The component type of the returned array is always the same as that of the input array.
ArrayUtils.removeElements(null, 1, 2) = null ArrayUtils.removeElements([], 1, 2) = [] ArrayUtils.removeElements([1], 2, 3) = [1] ArrayUtils.removeElements([1, 3], 1, 2) = [3] ArrayUtils.removeElements([1, 3, 1], 1) = [3, 1] ArrayUtils.removeElements([1, 3, 1], 1, 1) = [3]
array - the array to remove the element from, may be nullvalues - the elements to be removedpublic static long[] removeAll(long[] array,
int... indices)
Removes the elements at the specified positions from the specified array. All remaining elements are shifted to the left.
This method returns a new array with the same elements of the input array except those at the specified positions. 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.removeAll([1], 0) = [] ArrayUtils.removeAll([2, 6], 0) = [6] ArrayUtils.removeAll([2, 6], 0, 1) = [] ArrayUtils.removeAll([2, 6, 3], 1, 2) = [2] ArrayUtils.removeAll([2, 6, 3], 0, 2) = [6] ArrayUtils.removeAll([2, 6, 3], 0, 1, 2) = []
array - the array to remove the element from, may not be nullindices - the positions of the elements to be removedIndexOutOfBoundsException - if any index is out of range
(index < 0 || index >= array.length), or if the array is null.public static long[] removeElements(long[] array,
long... values)
Removes occurrences of specified elements, in specified quantities, from the specified array. All subsequent elements are shifted left. For any element-to-be-removed specified in greater quantities than contained in the original array, no change occurs beyond the removal of the existing matching items.
This method returns a new array with the same elements of the input array except for the earliest-encountered occurrences of the specified elements. The component type of the returned array is always the same as that of the input array.
ArrayUtils.removeElements(null, 1, 2) = null ArrayUtils.removeElements([], 1, 2) = [] ArrayUtils.removeElements([1], 2, 3) = [1] ArrayUtils.removeElements([1, 3], 1, 2) = [3] ArrayUtils.removeElements([1, 3, 1], 1) = [3, 1] ArrayUtils.removeElements([1, 3, 1], 1, 1) = [3]
array - the array to remove the element from, may be nullvalues - the elements to be removedpublic static float[] removeAll(float[] array,
int... indices)
Removes the elements at the specified positions from the specified array. All remaining elements are shifted to the left.
This method returns a new array with the same elements of the input array except those at the specified positions. 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.removeAll([1], 0) = [] ArrayUtils.removeAll([2, 6], 0) = [6] ArrayUtils.removeAll([2, 6], 0, 1) = [] ArrayUtils.removeAll([2, 6, 3], 1, 2) = [2] ArrayUtils.removeAll([2, 6, 3], 0, 2) = [6] ArrayUtils.removeAll([2, 6, 3], 0, 1, 2) = []
array - the array to remove the element from, may not be nullindices - the positions of the elements to be removedIndexOutOfBoundsException - if any index is out of range
(index < 0 || index >= array.length), or if the array is null.public static float[] removeElements(float[] array,
float... values)
Removes occurrences of specified elements, in specified quantities, from the specified array. All subsequent elements are shifted left. For any element-to-be-removed specified in greater quantities than contained in the original array, no change occurs beyond the removal of the existing matching items.
This method returns a new array with the same elements of the input array except for the earliest-encountered occurrences of the specified elements. The component type of the returned array is always the same as that of the input array.
ArrayUtils.removeElements(null, 1, 2) = null ArrayUtils.removeElements([], 1, 2) = [] ArrayUtils.removeElements([1], 2, 3) = [1] ArrayUtils.removeElements([1, 3], 1, 2) = [3] ArrayUtils.removeElements([1, 3, 1], 1) = [3, 1] ArrayUtils.removeElements([1, 3, 1], 1, 1) = [3]
array - the array to remove the element from, may be nullvalues - the elements to be removedpublic static double[] removeAll(double[] array,
int... indices)
Removes the elements at the specified positions from the specified array. All remaining elements are shifted to the left.
This method returns a new array with the same elements of the input array except those at the specified positions. 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.removeAll([1], 0) = [] ArrayUtils.removeAll([2, 6], 0) = [6] ArrayUtils.removeAll([2, 6], 0, 1) = [] ArrayUtils.removeAll([2, 6, 3], 1, 2) = [2] ArrayUtils.removeAll([2, 6, 3], 0, 2) = [6] ArrayUtils.removeAll([2, 6, 3], 0, 1, 2) = []
array - the array to remove the element from, may not be nullindices - the positions of the elements to be removedIndexOutOfBoundsException - if any index is out of range
(index < 0 || index >= array.length), or if the array is null.public static double[] removeElements(double[] array,
double... values)
Removes occurrences of specified elements, in specified quantities, from the specified array. All subsequent elements are shifted left. For any element-to-be-removed specified in greater quantities than contained in the original array, no change occurs beyond the removal of the existing matching items.
This method returns a new array with the same elements of the input array except for the earliest-encountered occurrences of the specified elements. The component type of the returned array is always the same as that of the input array.
ArrayUtils.removeElements(null, 1, 2) = null ArrayUtils.removeElements([], 1, 2) = [] ArrayUtils.removeElements([1], 2, 3) = [1] ArrayUtils.removeElements([1, 3], 1, 2) = [3] ArrayUtils.removeElements([1, 3, 1], 1) = [3, 1] ArrayUtils.removeElements([1, 3, 1], 1, 1) = [3]
array - the array to remove the element from, may be nullvalues - the elements to be removedpublic static boolean[] removeAll(boolean[] array,
int... indices)
Removes the elements at the specified positions from the specified array. All remaining elements are shifted to the left.
This method returns a new array with the same elements of the input array except those at the specified positions. 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.removeAll([true, false, true], 0, 2) = [false] ArrayUtils.removeAll([true, false, true], 1, 2) = [true]
array - the array to remove the element from, may not be nullindices - the positions of the elements to be removedIndexOutOfBoundsException - if any index is out of range
(index < 0 || index >= array.length), or if the array is null.public static boolean[] removeElements(boolean[] array,
boolean... values)
Removes occurrences of specified elements, in specified quantities, from the specified array. All subsequent elements are shifted left. For any element-to-be-removed specified in greater quantities than contained in the original array, no change occurs beyond the removal of the existing matching items.
This method returns a new array with the same elements of the input array except for the earliest-encountered occurrences of the specified elements. The component type of the returned array is always the same as that of the input array.
ArrayUtils.removeElements(null, true, false) = null ArrayUtils.removeElements([], true, false) = [] ArrayUtils.removeElements([true], false, false) = [true] ArrayUtils.removeElements([true, false], true, true) = [false] ArrayUtils.removeElements([true, false, true], true) = [false, true] ArrayUtils.removeElements([true, false, true], true, true) = [false]
array - the array to remove the element from, may be nullvalues - the elements to be removedpublic static <T extends Comparable<? super T>> boolean isSorted(T[] array)
This method checks whether the provided array is sorted according to the class's
compareTo method.
T - the datatype of the array to check, it must implement Comparablearray - the array to checkpublic static <T> boolean isSorted(T[] array,
Comparator<T> comparator)
This method checks whether the provided array is sorted according to the provided Comparator.
T - the datatype of the arrayarray - the array to checkcomparator - the Comparator to compare overpublic static boolean isSorted(int[] array)
This method checks whether the provided array is sorted according to natural ordering.
array - the array to checkpublic static boolean isSorted(long[] array)
This method checks whether the provided array is sorted according to natural ordering.
array - the array to checkpublic static boolean isSorted(short[] array)
This method checks whether the provided array is sorted according to natural ordering.
array - the array to checkpublic static boolean isSorted(double[] array)
This method checks whether the provided array is sorted according to natural ordering.
array - the array to checkpublic static boolean isSorted(float[] array)
This method checks whether the provided array is sorted according to natural ordering.
array - the array to checkpublic static boolean isSorted(byte[] array)
This method checks whether the provided array is sorted according to natural ordering.
array - the array to checkpublic static boolean isSorted(char[] array)
This method checks whether the provided array is sorted according to natural ordering.
array - the array to checkpublic static boolean isSorted(boolean[] array)
This method checks whether the provided array is sorted according to natural ordering
(false before true).
array - the array to checkpublic static boolean[] removeAllOccurences(boolean[] array,
boolean element)
All subsequent elements are shifted to the left (subtracts one from their indices).
If the array doesn't contains such an element, no elements are removed from the array.
null will be returned if the input array is null.
element - the element to removearray - the input arraypublic static char[] removeAllOccurences(char[] array,
char element)
All subsequent elements are shifted to the left (subtracts one from their indices).
If the array doesn't contains such an element, no elements are removed from the array.
null will be returned if the input array is null.
element - the element to removearray - the input arraypublic static byte[] removeAllOccurences(byte[] array,
byte element)
All subsequent elements are shifted to the left (subtracts one from their indices).
If the array doesn't contains such an element, no elements are removed from the array.
null will be returned if the input array is null.
element - the element to removearray - the input arraypublic static short[] removeAllOccurences(short[] array,
short element)
All subsequent elements are shifted to the left (subtracts one from their indices).
If the array doesn't contains such an element, no elements are removed from the array.
null will be returned if the input array is null.
element - the element to removearray - the input arraypublic static int[] removeAllOccurences(int[] array,
int element)
All subsequent elements are shifted to the left (subtracts one from their indices).
If the array doesn't contains such an element, no elements are removed from the array.
null will be returned if the input array is null.
element - the element to removearray - the input arraypublic static long[] removeAllOccurences(long[] array,
long element)
All subsequent elements are shifted to the left (subtracts one from their indices).
If the array doesn't contains such an element, no elements are removed from the array.
null will be returned if the input array is null.
element - the element to removearray - the input arraypublic static float[] removeAllOccurences(float[] array,
float element)
All subsequent elements are shifted to the left (subtracts one from their indices).
If the array doesn't contains such an element, no elements are removed from the array.
null will be returned if the input array is null.
element - the element to removearray - the input arraypublic static double[] removeAllOccurences(double[] array,
double element)
All subsequent elements are shifted to the left (subtracts one from their indices).
If the array doesn't contains such an element, no elements are removed from the array.
null will be returned if the input array is null.
element - the element to removearray - the input arraypublic static <T> T[] removeAllOccurences(T[] array,
T element)
All subsequent elements are shifted to the left (subtracts one from their indices).
If the array doesn't contains such an element, no elements are removed from the array.
null will be returned if the input array is null.
T - the type of object in the arrayelement - the element to removearray - the input arraypublic static String[] toStringArray(Object[] array)
Returns an array containing the string representation of each element in the argument array.
This method returns null for a null input array.
array - the Object[] to be processed, may be nullString[] of the same size as the source with its element's string representation,
null if null array inputNullPointerException - if array contains nullpublic static String[] toStringArray(Object[] array, String valueForNullElements)
Returns an array containing the string representation of each element in the argument
array handling null elements.
This method returns null for a null input array.
array - the Object[] to be processed, may be nullvalueForNullElements - the value to insert if null is foundString array, null if null array inputpublic static <T> Object insert(Object array, int index, T... newElements)
T - 数组元素类型array - 已有数组index - 插入位置,此位置为对应此位置元素之前的空档newElements - 新元素public static boolean[] insert(int index,
boolean[] array,
boolean... values)
Inserts elements into an array at the given index (starting from zero).
When an array is returned, it is always a new array.
ArrayUtils.insert(index, null, null) = null ArrayUtils.insert(index, array, null) = cloned copy of 'array' ArrayUtils.insert(index, null, values) = null
index - the position within array to insert the new valuesarray - the array to insert the values into, may be nullvalues - the new values to insert, may be nullIndexOutOfBoundsException - if array is provided
and either index < 0 or index > array.lengthpublic static byte[] insert(int index,
byte[] array,
byte... values)
Inserts elements into an array at the given index (starting from zero).
When an array is returned, it is always a new array.
ArrayUtils.insert(index, null, null) = null ArrayUtils.insert(index, array, null) = cloned copy of 'array' ArrayUtils.insert(index, null, values) = null
index - the position within array to insert the new valuesarray - the array to insert the values into, may be nullvalues - the new values to insert, may be nullIndexOutOfBoundsException - if array is provided
and either index < 0 or index > array.lengthpublic static char[] insert(int index,
char[] array,
char... values)
Inserts elements into an array at the given index (starting from zero).
When an array is returned, it is always a new array.
ArrayUtils.insert(index, null, null) = null ArrayUtils.insert(index, array, null) = cloned copy of 'array' ArrayUtils.insert(index, null, values) = null
index - the position within array to insert the new valuesarray - the array to insert the values into, may be nullvalues - the new values to insert, may be nullIndexOutOfBoundsException - if array is provided
and either index < 0 or index > array.lengthpublic static double[] insert(int index,
double[] array,
double... values)
Inserts elements into an array at the given index (starting from zero).
When an array is returned, it is always a new array.
ArrayUtils.insert(index, null, null) = null ArrayUtils.insert(index, array, null) = cloned copy of 'array' ArrayUtils.insert(index, null, values) = null
index - the position within array to insert the new valuesarray - the array to insert the values into, may be nullvalues - the new values to insert, may be nullIndexOutOfBoundsException - if array is provided
and either index < 0 or index > array.lengthpublic static float[] insert(int index,
float[] array,
float... values)
Inserts elements into an array at the given index (starting from zero).
When an array is returned, it is always a new array.
ArrayUtils.insert(index, null, null) = null ArrayUtils.insert(index, array, null) = cloned copy of 'array' ArrayUtils.insert(index, null, values) = null
index - the position within array to insert the new valuesarray - the array to insert the values into, may be nullvalues - the new values to insert, may be nullIndexOutOfBoundsException - if array is provided
and either index < 0 or index > array.lengthpublic static int[] insert(int index,
int[] array,
int... values)
Inserts elements into an array at the given index (starting from zero).
When an array is returned, it is always a new array.
ArrayUtils.insert(index, null, null) = null ArrayUtils.insert(index, array, null) = cloned copy of 'array' ArrayUtils.insert(index, null, values) = null
index - the position within array to insert the new valuesarray - the array to insert the values into, may be nullvalues - the new values to insert, may be nullIndexOutOfBoundsException - if array is provided
and either index < 0 or index > array.lengthpublic static long[] insert(int index,
long[] array,
long... values)
Inserts elements into an array at the given index (starting from zero).
When an array is returned, it is always a new array.
ArrayUtils.insert(index, null, null) = null ArrayUtils.insert(index, array, null) = cloned copy of 'array' ArrayUtils.insert(index, null, values) = null
index - the position within array to insert the new valuesarray - the array to insert the values into, may be nullvalues - the new values to insert, may be nullIndexOutOfBoundsException - if array is provided
and either index < 0 or index > array.lengthpublic static short[] insert(int index,
short[] array,
short... values)
Inserts elements into an array at the given index (starting from zero).
When an array is returned, it is always a new array.
ArrayUtils.insert(index, null, null) = null ArrayUtils.insert(index, array, null) = cloned copy of 'array' ArrayUtils.insert(index, null, values) = null
index - the position within array to insert the new valuesarray - the array to insert the values into, may be nullvalues - the new values to insert, may be nullIndexOutOfBoundsException - if array is provided
and either index < 0 or index > array.lengthpublic static <T> T[] insert(int index,
T[] array,
T... values)
Inserts elements into an array at the given index (starting from zero).
When an array is returned, it is always a new array.
ArrayUtils.insert(index, null, null) = null ArrayUtils.insert(index, array, null) = cloned copy of 'array' ArrayUtils.insert(index, null, values) = null
T - The type of elements in array and valuesindex - the position within array to insert the new valuesarray - the array to insert the values into, may be nullvalues - the new values to insert, may be nullIndexOutOfBoundsException - if array is provided
and either index < 0 or index > array.lengthpublic static void shuffle(Object[] array)
array - the array to shufflepublic static void shuffle(Object[] array, Random random)
array - the array to shufflerandom - the source of randomness used to permute the elementspublic static void shuffle(boolean[] array)
array - the array to shufflepublic static void shuffle(boolean[] array,
Random random)
array - the array to shufflerandom - the source of randomness used to permute the elementspublic static void shuffle(byte[] array)
array - the array to shufflepublic static void shuffle(byte[] array,
Random random)
array - the array to shufflerandom - the source of randomness used to permute the elementspublic static void shuffle(char[] array)
array - the array to shufflepublic static void shuffle(char[] array,
Random random)
array - the array to shufflerandom - the source of randomness used to permute the elementspublic static void shuffle(short[] array)
array - the array to shufflepublic static void shuffle(short[] array,
Random random)
array - the array to shufflerandom - the source of randomness used to permute the elementspublic static void shuffle(int[] array)
array - the array to shufflepublic static void shuffle(int[] array,
Random random)
array - the array to shufflerandom - the source of randomness used to permute the elementspublic static void shuffle(long[] array)
array - the array to shufflepublic static void shuffle(long[] array,
Random random)
array - the array to shufflerandom - the source of randomness used to permute the elementspublic static void shuffle(float[] array)
array - the array to shufflepublic static void shuffle(float[] array,
Random random)
array - the array to shufflerandom - the source of randomness used to permute the elementspublic static void shuffle(double[] array)
array - the array to shufflepublic static void shuffle(double[] array,
Random random)
array - the array to shufflerandom - the source of randomness used to permute the elementspublic static <T> boolean isArrayIndexValid(T[] array,
int index)
T - the component type of the arrayarray - the array to inspect, may be nullindex - the index of the array to be inspectedpublic static <T> boolean hasNull(T... array)
null元素T - 数组元素类型array - 被检查的数组public static <T> T firstNonNull(T... array)
T - 数组元素类型array - 数组nullpublic static <T> T[] newArray(Class<?> componentType, int newSize)
T - 数组元素类型componentType - 元素类型newSize - 大小public static <T> T[] newArray(int newSize)
T - 数组元素类型newSize - 大小public static Class<?> getComponentType(Object array)
array - 数组对象public static Class<?> getComponentType(Class<?> arrayClass)
arrayClass - 数组类public static Class<?> getArrayType(Class<?> componentType)
componentType - 数组元素类型public static Object[] cast(Class<?> type, Object arrayObj) throws NullPointerException, IllegalArgumentException
type - 数组类型或数组元素类型arrayObj - 原数组NullPointerException - 提供参数为空IllegalArgumentException - 参数arrayObj不是数组public static <T> T[] append(T[] buffer,
T... newElements)
T - 数组元素类型buffer - 已有数组newElements - 新元素public static <T> Object append(Object array, T... newElements)
T - 数组元素类型array - 已有数组newElements - 新元素public static <T> T[] setOrAppend(T[] buffer,
int index,
T value)
T - 数组元素类型buffer - 已有数组index - 位置,大于长度追加,否则替换value - 新值public static Object setOrAppend(Object array, int index, Object value)
array - 已有数组index - 位置,大于长度追加,否则替换value - 新值public static <T> T[] insert(T[] array,
int index,
T... newElements)
public static <T> T[] resize(T[] buffer,
int newSize,
Class<?> componentType)
T - 数组元素类型buffer - 原数组newSize - 新的数组大小componentType - 数组元素类型public static <T> T[] resize(T[] buffer,
int newSize)
T - 数组元素类型buffer - 原数组newSize - 新的数组大小public static <T> T[] addAll(T[]... arrays)
T - 数组元素类型arrays - 数组集合public static Object copy(Object src, int srcPos, Object dest, int destPos, int length)
src - 源数组srcPos - 源数组开始位置dest - 目标数组destPos - 目标数组开始位置length - 拷贝数组长度public static Object copy(Object src, Object dest, int length)
System.arraycopy(Object, int, Object, int, int)src - 源数组dest - 目标数组length - 拷贝数组长度public static int[] range(int excludedEnd)
excludedEnd - 结束的数字(不包含)public static int[] range(int includedStart,
int excludedEnd)
includedStart - 开始的数字(包含)excludedEnd - 结束的数字(不包含)public static int[] range(int includedStart,
int excludedEnd,
int step)
includedStart - 开始的数字(包含)excludedEnd - 结束的数字(不包含)step - 步进public static byte[][] split(byte[] array,
int len)
array - 数组len - 每个小节的长度public static int indexOfIgnoreCase(CharSequence[] array, CharSequence value)
INDEX_NOT_FOUNDarray - 数组value - 被检查的元素INDEX_NOT_FOUNDpublic static int[] unWrap(Integer... values)
values - 包装类型数组public static Long[] wrap(long... values)
values - 原始类型数组public static long[] unWrap(Long... values)
values - 包装类型数组public static Character[] wrap(char... values)
values - 原始类型数组public static char[] unWrap(Character... values)
values - 包装类型数组public static Byte[] wrap(byte... values)
values - 原始类型数组public static byte[] unWrap(Byte... values)
values - 包装类型数组public static Short[] wrap(short... values)
values - 原始类型数组public static short[] unWrap(Short... values)
values - 包装类型数组public static Float[] wrap(float... values)
values - 原始类型数组public static float[] unWrap(Float... values)
values - 包装类型数组public static Double[] wrap(double... values)
values - 原始类型数组public static double[] unWrap(Double... values)
values - 包装类型数组public static Boolean[] wrap(boolean... values)
values - 原始类型数组public static boolean[] unWrap(Boolean... values)
values - 包装类型数组public static Object[] wrap(Object obj)
obj - 对象,可以是对象数组或者基本类型数组CommonException - 对象为非数组public static boolean isArray(Object obj)
obj - 对象null 返回falsepublic static <T> T get(Object array, int index)
T - 数组元素类型array - 数组对象index - 下标,支持负数public static <T> T[] getAny(Object array, int... indexes)
T - 数组元素类型array - 数组indexes - 下标列表public static Object[] sub(Object array, int start, int end)
array - 数组start - 开始位置(包括)end - 结束位置(不包括)public static Object[] sub(Object array, int start, int end, int step)
array - 数组start - 开始位置(包括)end - 结束位置(不包括)step - 步进public static int length(Object array) throws IllegalArgumentException
null,返回0
ArrayUtils.length(null) = 0 ArrayUtils.length([]) = 0 ArrayUtils.length([null]) = 1 ArrayUtils.length([true, false]) = 2 ArrayUtils.length([1, 2, 3]) = 3 ArrayUtils.length(["a", "b", "c"]) = 3
array - 数组对象IllegalArgumentException - 如果参数不为数组,抛出此异常Array.getLength(Object)public static String join(long[] array, CharSequence conjunction)
array - 数组conjunction - 分隔符public static <T> String join(T[] array, CharSequence conjunction, String prefix, String suffix)
T - 被处理的集合array - 数组conjunction - 分隔符prefix - 每个元素添加的前缀,null表示不添加suffix - 每个元素添加的后缀,null表示不添加public static String join(int[] array, CharSequence conjunction)
array - 数组conjunction - 分隔符public static String join(short[] array, CharSequence conjunction)
array - 数组conjunction - 分隔符public static String join(char[] array, CharSequence conjunction)
array - 数组conjunction - 分隔符public static String join(byte[] array, CharSequence conjunction)
array - 数组conjunction - 分隔符public static String join(boolean[] array, CharSequence conjunction)
array - 数组conjunction - 分隔符public static String join(float[] array, CharSequence conjunction)
array - 数组conjunction - 分隔符public static String join(double[] array, CharSequence conjunction)
array - 数组conjunction - 分隔符public static String join(Object array, CharSequence conjunction)
array - 数组conjunction - 分隔符public static byte[] toArray(ByteBuffer bytebuffer)
ByteBuffer 转byte数组bytebuffer - ByteBufferpublic static <T> T[] toArray(Collection<T> collection, Class<T> componentType)
T - 数组元素类型collection - 集合componentType - 集合元素类型public static <T extends Comparable<? super T>> T min(T[] numberArray)
T - 元素类型numberArray - 数字数组public static long min(long... numberArray)
numberArray - 数字数组public static int min(int... numberArray)
numberArray - 数字数组public static short min(short... numberArray)
numberArray - 数字数组public static char min(char... numberArray)
numberArray - 数字数组public static byte min(byte... numberArray)
numberArray - 数字数组public static double min(double... numberArray)
numberArray - 数字数组public static float min(float... numberArray)
numberArray - 数字数组public static <T extends Comparable<? super T>> T max(T[] numberArray)
T - 元素类型numberArray - 数字数组public static long max(long... numberArray)
numberArray - 数字数组public static int max(int... numberArray)
numberArray - 数字数组public static short max(short... numberArray)
numberArray - 数字数组public static char max(char... numberArray)
numberArray - 数字数组public static byte max(byte... numberArray)
numberArray - 数字数组public static double max(double... numberArray)
numberArray - 数字数组public static float max(float... numberArray)
numberArray - 数字数组public static <K,V> Map<K,V> zip(K[] keys, V[] values, boolean isOrder)
K - Key类型V - Value类型keys - 键列表values - 值列表isOrder - 是否有序public static <T> T[] filter(T[] array,
Editor<T> editor)
1、过滤出需要的对象,如果返回null表示这个元素对象抛弃 2、修改元素对象,返回集合中为修改后的对象
T - 数组元素类型array - 数组editor - 编辑器接口public static <T> T[] filter(T[] array,
Filter<T> filter)
T - 数组元素类型array - 数组filter - 过滤器接口,用于定义过滤规则public static boolean containsIgnoreCase(CharSequence[] array, CharSequence value)
array - 数组value - 被检查的元素Copyright © 2019. All rights reserved.