public class ArrayTools extends Object
数组工具类
| Modifier and Type | Field and Description |
|---|---|
static byte[] |
EMPTY_BYTE_ARRAY |
static char[] |
EMPTY_CHAR_ARRAY |
static double[] |
EMPTY_DOUBLE_ARRAY |
static float[] |
EMPTY_FLOAT_ARRAY |
static int[] |
EMPTY_INT_ARRAY |
static long[] |
EMPTY_LONG_ARRAY |
static short[] |
EMPTY_SHORT_ARRAY |
static int |
NOT_FOUND_INDEX |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
concatByteArray(Collection<byte[]> arrays)
拼接多个数组
|
static char[] |
concatCharArray(Collection<char[]> arrays)
拼接多个数组
|
static double[] |
concatDoubleArray(Collection<double[]> arrays)
拼接多个数组
|
static float[] |
concatFloatArray(Collection<float[]> arrays)
拼接多个数组
|
static int[] |
concatIntArray(Collection<int[]> arrays)
拼接多个数组
|
static long[] |
concatLongArray(Collection<long[]> arrays)
拼接多个数组
|
static short[] |
concatShortArray(Collection<short[]> arrays)
拼接多个数组
|
static <T> List<T> |
concatToList(Collection<T[]> arrays)
将集合中的数组连接为一个列表
|
static boolean |
contains(byte[] arr,
byte obj) |
static boolean |
contains(char[] arr,
char obj) |
static boolean |
contains(double[] arr,
double obj) |
static boolean |
contains(float[] arr,
float obj) |
static boolean |
contains(int[] arr,
int obj) |
static boolean |
contains(long[] arr,
long obj) |
static boolean |
contains(short[] arr,
short obj) |
static <T> boolean |
contains(T[] arr,
T obj) |
static boolean |
containsValue(BigDecimal[] arr,
BigDecimal obj) |
static void |
fill(byte[] a,
byte[] values)
填充数组
|
static void |
fill(byte[] a,
int fromIndex,
int toIndex,
byte[] values)
填充数组
|
static void |
fill(char[] a,
char[] values)
填充数组
|
static void |
fill(char[] a,
int fromIndex,
int toIndex,
char[] values)
填充数组
|
static void |
fill(char[] a,
String values)
填充数组
|
static void |
fill(double[] a,
double[] values)
填充数组
|
static void |
fill(double[] a,
int fromIndex,
int toIndex,
double[] values)
填充数组
|
static void |
fill(float[] a,
float[] values)
填充数组
|
static void |
fill(float[] a,
int fromIndex,
int toIndex,
float[] values)
填充数组
|
static void |
fill(int[] a,
int[] values)
填充数组
|
static void |
fill(int[] a,
int fromIndex,
int toIndex,
int[] values)
填充数组
|
static void |
fill(long[] a,
int fromIndex,
int toIndex,
long[] values)
填充数组
|
static void |
fill(long[] a,
long[] values)
填充数组
|
static void |
fill(short[] a,
int fromIndex,
int toIndex,
short[] values)
填充数组
|
static void |
fill(short[] a,
short[] values)
填充数组
|
static <T> void |
fill(T[] a,
int fromIndex,
int toIndex,
T[] values)
填充数组
|
static <T> void |
fill(T[] a,
T[] values)
填充数组
|
static int |
indexOf(byte[] arr,
byte value) |
static int |
indexOf(char[] arr,
char value) |
static int |
indexOf(double[] arr,
double value) |
static int |
indexOf(float[] arr,
float value) |
static int |
indexOf(int[] arr,
int value) |
static int |
indexOf(long[] arr,
long value) |
static int |
indexOf(short[] arr,
short value) |
static <T> int |
indexOf(T[] arr,
Predicate<? super T> predicate) |
static <T> int |
indexOf(T[] arr,
T obj) |
static <T> boolean |
isAllElementsNotNull(T[] arr)
判断数组的所有元素是否都不为空:
数组为
null:抛出异常,因为传入 null 通常被视为编程错误。 |
static boolean |
isEmpty(byte[] arr)
检查给定数组是否为空
|
static boolean |
isEmpty(char[] arr)
检查给定数组是否为空
|
static boolean |
isEmpty(double[] arr)
检查给定数组是否为空
|
static boolean |
isEmpty(float[] arr)
检查给定数组是否为空
|
static boolean |
isEmpty(int[] arr)
检查给定数组是否为空
|
static boolean |
isEmpty(long[] arr)
检查给定数组是否为空
|
static boolean |
isEmpty(short[] arr)
检查给定数组是否为空
|
static <T> boolean |
isEmpty(T[] arr)
检查给定数组是否为空
|
static boolean |
isNotEmpty(byte[] arr)
检查给定数组是否不为空
|
static boolean |
isNotEmpty(char[] arr)
检查给定数组是否不为空
|
static boolean |
isNotEmpty(double[] arr)
检查给定数组是否不为空
|
static boolean |
isNotEmpty(float[] arr)
检查给定数组是否不为空
|
static boolean |
isNotEmpty(int[] arr)
检查给定数组是否不为空
|
static boolean |
isNotEmpty(long[] arr)
检查给定数组是否不为空
|
static boolean |
isNotEmpty(short[] arr)
检查给定数组是否不为空
|
static <T> boolean |
isNotEmpty(T[] arr)
检查给定数组是否不为空
|
static int |
lastIndexOf(byte[] arr,
byte value) |
static int |
lastIndexOf(char[] arr,
char value) |
static int |
lastIndexOf(double[] arr,
double value) |
static int |
lastIndexOf(float[] arr,
float value) |
static int |
lastIndexOf(int[] arr,
int value) |
static int |
lastIndexOf(long[] arr,
long value) |
static int |
lastIndexOf(short[] arr,
short value) |
static <T> int |
lastIndexOf(T[] arr,
Predicate<? super T> predicate) |
static <T> int |
lastIndexOf(T[] arr,
T obj) |
static byte[] |
repeat(byte[] arr,
int times)
重复数组中的元素
|
static byte[] |
repeat(byte[] arr,
int times,
int maxLength)
重复数组中的元素
|
static char[] |
repeat(char[] arr,
int times)
重复数组中的元素
|
static char[] |
repeat(char[] arr,
int times,
int maxLength)
重复数组中的元素
|
static double[] |
repeat(double[] arr,
int times)
重复数组中的元素
|
static double[] |
repeat(double[] arr,
int times,
int maxLength)
重复数组中的元素
|
static float[] |
repeat(float[] arr,
int times)
重复数组中的元素
|
static float[] |
repeat(float[] arr,
int times,
int maxLength)
重复数组中的元素
|
static int[] |
repeat(int[] arr,
int times)
重复数组中的元素
|
static int[] |
repeat(int[] arr,
int times,
int maxLength)
重复数组中的元素
|
static long[] |
repeat(long[] arr,
int times)
重复数组中的元素
|
static long[] |
repeat(long[] arr,
int times,
int maxLength)
重复数组中的元素
|
static short[] |
repeat(short[] arr,
int times)
重复数组中的元素
|
static short[] |
repeat(short[] arr,
int times,
int maxLength)
重复数组中的元素
|
public static final char[] EMPTY_CHAR_ARRAY
public static final byte[] EMPTY_BYTE_ARRAY
public static final short[] EMPTY_SHORT_ARRAY
public static final int[] EMPTY_INT_ARRAY
public static final long[] EMPTY_LONG_ARRAY
public static final float[] EMPTY_FLOAT_ARRAY
public static final double[] EMPTY_DOUBLE_ARRAY
public static final int NOT_FOUND_INDEX
public static <T> boolean isEmpty(@Nullable T[] arr)
T - 数组中元素的类型arr - 待检查的数组,可以为 nullnull 或长度为 0,则返回 true;否则返回 falsepublic static boolean isEmpty(@Nullable char[] arr)
arr - 待检查的数组,可以为 nullnull 或长度为 0,则返回 true;否则返回 falsepublic static boolean isEmpty(@Nullable byte[] arr)
arr - 待检查的数组,可以为 nullnull 或长度为 0,则返回 true;否则返回 falsepublic static boolean isEmpty(@Nullable short[] arr)
arr - 待检查的数组,可以为 nullnull 或长度为 0,则返回 true;否则返回 falsepublic static boolean isEmpty(@Nullable int[] arr)
arr - 待检查的数组,可以为 nullnull 或长度为 0,则返回 true;否则返回 falsepublic static boolean isEmpty(@Nullable long[] arr)
arr - 待检查的数组,可以为 nullnull 或长度为 0,则返回 true;否则返回 falsepublic static boolean isEmpty(@Nullable float[] arr)
arr - 待检查的数组,可以为 nullnull 或长度为 0,则返回 true;否则返回 falsepublic static boolean isEmpty(@Nullable double[] arr)
arr - 待检查的数组,可以为 nullnull 或长度为 0,则返回 true;否则返回 falsepublic static <T> boolean isNotEmpty(@Nullable T[] arr)
T - 数组中元素的类型arr - 待检查的数组,可以为 nullnull 且长度大于 0,则返回 true;否则返回 falsepublic static boolean isNotEmpty(@Nullable char[] arr)
arr - 待检查的数组,可以为 nullnull 且长度大于 0,则返回 true;否则返回 falsepublic static boolean isNotEmpty(@Nullable byte[] arr)
arr - 待检查的数组,可以为 nullnull 且长度大于 0,则返回 true;否则返回 falsepublic static boolean isNotEmpty(@Nullable short[] arr)
arr - 待检查的数组,可以为 nullnull 且长度大于 0,则返回 true;否则返回 falsepublic static boolean isNotEmpty(@Nullable int[] arr)
arr - 待检查的数组,可以为 nullnull 且长度大于 0,则返回 true;否则返回 falsepublic static boolean isNotEmpty(@Nullable long[] arr)
arr - 待检查的数组,可以为 nullnull 且长度大于 0,则返回 true;否则返回 falsepublic static boolean isNotEmpty(@Nullable float[] arr)
arr - 待检查的数组,可以为 nullnull 且长度大于 0,则返回 true;否则返回 falsepublic static boolean isNotEmpty(@Nullable double[] arr)
arr - 待检查的数组,可以为 nullnull 且长度大于 0,则返回 true;否则返回 falsepublic static <T> boolean isAllElementsNotNull(@Nullable T[] arr)
null:抛出异常,因为传入 null 通常被视为编程错误。
null 但长度为 0:在这种情况下,通常认为数组中的所有元素都不为 null,因此返回 null。
null:返回 false。
null:返回 true。
T - 数组元素的类型arr - 待检查的数组。不为 nullnull,则返回 true;否则返回 falseIllegalArgumentException - 当参数为空时抛出public static char[] concatCharArray(@Nullable Collection<char[]> arrays)
arrays - 数组集合,可以为 nullpublic static byte[] concatByteArray(@Nullable Collection<byte[]> arrays)
arrays - 数组集合,可以为 nullpublic static short[] concatShortArray(@Nullable Collection<short[]> arrays)
arrays - 数组集合,可以为 nullpublic static int[] concatIntArray(@Nullable Collection<int[]> arrays)
arrays - 数组集合,可以为 nullpublic static long[] concatLongArray(@Nullable Collection<long[]> arrays)
arrays - 数组集合,可以为 nullpublic static float[] concatFloatArray(@Nullable Collection<float[]> arrays)
arrays - 数组集合,可以为 nullpublic static double[] concatDoubleArray(@Nullable Collection<double[]> arrays)
arrays - 数组集合,可以为 nullpublic static <T> List<T> concatToList(@Nullable Collection<T[]> arrays)
T - 泛型参数,表示数组的元素类型arrays - 可能包含多个数组的集合,这些数组中的元素将被连接到一个列表中public static char[] repeat(char[] arr,
int times)
arr - 重复内容times - 重复次数public static char[] repeat(char[] arr,
int times,
int maxLength)
arr - 重复内容times - 重复次数maxLength - 最大长度public static byte[] repeat(byte[] arr,
int times)
arr - 重复内容times - 重复次数public static byte[] repeat(byte[] arr,
int times,
int maxLength)
arr - 重复内容times - 重复次数maxLength - 最大长度public static short[] repeat(short[] arr,
int times)
arr - 重复内容times - 重复次数public static short[] repeat(short[] arr,
int times,
int maxLength)
arr - 重复内容times - 重复次数maxLength - 最大长度public static int[] repeat(int[] arr,
int times)
arr - 重复内容times - 重复次数public static int[] repeat(int[] arr,
int times,
int maxLength)
arr - 重复内容times - 重复次数maxLength - 最大长度public static long[] repeat(long[] arr,
int times)
arr - 重复内容times - 重复次数public static long[] repeat(long[] arr,
int times,
int maxLength)
arr - 重复内容times - 重复次数maxLength - 最大长度public static float[] repeat(float[] arr,
int times)
arr - 重复内容times - 重复次数public static float[] repeat(float[] arr,
int times,
int maxLength)
arr - 重复内容times - 重复次数maxLength - 最大长度public static double[] repeat(double[] arr,
int times)
arr - 重复内容times - 重复次数public static double[] repeat(double[] arr,
int times,
int maxLength)
arr - 重复内容times - 重复次数maxLength - 最大长度public static void fill(char[] a,
@Nullable
char[] values)
a - 要填充的数组values - 填充内容public static void fill(char[] a,
@Nullable
String values)
a - 要填充的数组values - 填充内容public static void fill(char[] a,
int fromIndex,
int toIndex,
@Nullable
char[] values)
a - 要填充的数组fromIndex - 开始位置toIndex - 结束位置values - 填充内容public static void fill(byte[] a,
@Nullable
byte[] values)
a - 要填充的数组values - 填充内容public static void fill(byte[] a,
int fromIndex,
int toIndex,
@Nullable
byte[] values)
a - 要填充的数组fromIndex - 开始位置toIndex - 结束位置values - 填充内容public static void fill(short[] a,
@Nullable
short[] values)
a - 要填充的数组values - 填充内容public static void fill(short[] a,
int fromIndex,
int toIndex,
@Nullable
short[] values)
a - 要填充的数组fromIndex - 开始位置toIndex - 结束位置values - 填充内容public static void fill(int[] a,
@Nullable
int[] values)
a - 要填充的数组values - 填充内容public static void fill(int[] a,
int fromIndex,
int toIndex,
@Nullable
int[] values)
a - 要填充的数组fromIndex - 开始位置toIndex - 结束位置values - 填充内容public static void fill(long[] a,
@Nullable
long[] values)
a - 要填充的数组values - 填充内容public static void fill(long[] a,
int fromIndex,
int toIndex,
@Nullable
long[] values)
a - 要填充的数组fromIndex - 开始位置toIndex - 结束位置values - 填充内容public static void fill(float[] a,
@Nullable
float[] values)
a - 要填充的数组values - 填充内容public static void fill(float[] a,
int fromIndex,
int toIndex,
@Nullable
float[] values)
a - 要填充的数组fromIndex - 开始位置toIndex - 结束位置values - 填充内容public static void fill(double[] a,
@Nullable
double[] values)
a - 要填充的数组values - 填充内容public static void fill(double[] a,
int fromIndex,
int toIndex,
@Nullable
double[] values)
a - 要填充的数组fromIndex - 开始位置toIndex - 结束位置values - 填充内容public static <T> void fill(T[] a,
@Nullable
T[] values)
a - 要填充的数组values - 填充内容public static <T> void fill(T[] a,
int fromIndex,
int toIndex,
@Nullable
T[] values)
a - 要填充的数组fromIndex - 开始位置toIndex - 结束位置values - 填充内容public static int indexOf(@Nullable char[] arr, char value)
public static int indexOf(@Nullable byte[] arr, byte value)
public static int indexOf(@Nullable short[] arr, short value)
public static int indexOf(@Nullable int[] arr, int value)
public static int indexOf(@Nullable long[] arr, long value)
public static int indexOf(@Nullable float[] arr, float value)
public static int indexOf(@Nullable double[] arr, double value)
public static <T> int lastIndexOf(T[] arr,
T obj)
public static int lastIndexOf(@Nullable char[] arr, char value)
public static int lastIndexOf(@Nullable byte[] arr, byte value)
public static int lastIndexOf(@Nullable short[] arr, short value)
public static int lastIndexOf(@Nullable int[] arr, int value)
public static int lastIndexOf(@Nullable long[] arr, long value)
public static int lastIndexOf(@Nullable float[] arr, float value)
public static int lastIndexOf(@Nullable double[] arr, double value)
public static boolean contains(@Nullable char[] arr, char obj)
public static boolean contains(@Nullable byte[] arr, byte obj)
public static boolean contains(@Nullable short[] arr, short obj)
public static boolean contains(@Nullable int[] arr, int obj)
public static boolean contains(@Nullable long[] arr, long obj)
public static boolean contains(@Nullable float[] arr, float obj)
public static boolean contains(@Nullable double[] arr, double obj)
public static boolean containsValue(@Nullable BigDecimal[] arr, @Nullable BigDecimal obj)
Copyright © 2026. All rights reserved.