public class ArrayUtils
extends java.lang.Object
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> T[] |
addAll(T[] array1,
T... array2)
Adds all the elements of the given arrays into a new array.
|
static <T> T[] |
cleanNull(T[] array)
清除array中为
null的元素 |
static <T> T[] |
clone(T[] array)
Shallow clones an array returning a typecast result and handling
null. |
static boolean |
hasNull(java.lang.Object... objects) |
static int |
indexOfFirstNull(java.lang.Object... objects)
返回第一个为
null元素的索引,没找到返回-1,如果输入为null则返回-2 |
public static final <T> T[] cleanNull(T[] array)
null的元素array - 输入的数组null或长度为0或array中没有null元素则返回array,否则返回新的不含null的数组public static int indexOfFirstNull(java.lang.Object... objects)
null元素的索引,没找到返回-1,如果输入为null则返回-2objects - public static boolean hasNull(java.lang.Object... objects)
objects - 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.java.lang.IllegalArgumentException - if the array types are incompatiblepublic static <T> T[] clone(T[] array)
Shallow clones an array returning a typecast result and handling
null.
The objects in the array are not cloned, thus there is no special handling for multi-dimensional arrays.
This method returns null for a null input array.
T - the component type of the arrayarray - the array to shallow clone, may be nullnull if null inputCopyright © 2023. All Rights Reserved.