public final class ArrayUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String[] |
STRING_EMPTY
空字符串列表
|
| 限定符和类型 | 方法和说明 |
|---|---|
static <E> List<E> |
arrayToList(E... array)
数组转列表
(1)如果为空,则直接转为空。
|
static boolean |
contains(Object[] array,
Object objectToFind)
是否包含数据
|
static Optional<Object> |
firstNotNullElem(Object[] objects)
找到第一个不为 null 的元素
|
static int |
getEndIndex(int endIndex,
Object[] arrays)
获取开始的下标
(1)默认为0
(2)如果为负数,或者超过 arrays.length-1,则使用 arrays.length-1
(3)正常返回 endIndex
|
static int |
getStartIndex(int startIndex,
Object[] arrays)
获取开始的下标
(1)默认为0
(2)如果为负数,或者超过 arrays.length-1,则使用 0
(3)正常返回 startIndex
|
static int |
indexOf(Object[] array,
Object objectToFind)
查询对应元素的下标
|
static int |
indexOf(Object[] array,
Object objectToFind,
int startIndex)
查询对应元素的下标
|
static boolean |
isEmpty(Object[] objects)
数组是否为空
|
static boolean |
isNotEmpty(Object[] objects)
数组是否不为空
|
static int |
lastIndexOf(char[] chars,
char c)
最后索引
|
static int |
lastIndexOf(char[] chars,
char c,
int startIndex,
int endIndex)
最后索引
|
static <R> R[] |
listToArray(List<R> list)
列表转数组
|
static Object[] |
newArray(Object... objects)
返回数组信息
|
static boolean |
notContains(Object[] array,
Object objectToFind)
是否不包含数据
|
static Object[] |
shift(Object[] array,
int offset)
执行平移操作
1.
|
static Object[] |
toArray(List<?> objectList)
转换为数组
|
static <K,V> K[] |
toArray(V[] values,
IHandler<? super V,K> keyFunction)
数组转换为数组
(1)通过一层转换
|
static List |
toList(Object arrayObject,
IHandler keyFunction)
long 可遍历的元素对象的某个元素,转换为列表
|
static <T> List<T> |
toList(T[] objects)
数组转换为列表
|
static <K,V> List<K> |
toList(V[] values,
IHandler<? super V,K> keyFunction)
可遍历的元素对象的某个元素,转换为列表
|
static <K> K[] |
union(K[] values,
K... others)
数组的并集
|
public static final String[] STRING_EMPTY
public static boolean isEmpty(Object[] objects)
objects - 数组对象public static boolean isNotEmpty(Object[] objects)
objects - 数组对象public static <T> List<T> toList(T[] objects)
T - 泛型objects - 数组public static <K,V> K[] toArray(V[] values,
IHandler<? super V,K> keyFunction)
K - 泛型 KV - 泛型 Vvalues - 集合keyFunction - 处理函数public static <K> K[] union(K[] values,
K... others)
K - 泛型values - 集合others - 其他数组信息public static boolean contains(Object[] array, Object objectToFind)
array - 数组信息objectToFind - 待发现的对象public static boolean notContains(Object[] array, Object objectToFind)
array - 数组信息objectToFind - 待发现的对象public static int indexOf(Object[] array, Object objectToFind)
array - 数组信息objectToFind - 待发现的对象public static int indexOf(Object[] array, Object objectToFind, int startIndex)
array - 数组信息objectToFind - 待发现的对象startIndex - 开始下标public static <R> R[] listToArray(List<R> list)
R - 泛型list - 列表public static <E> List<E> arrayToList(E... array)
E - 泛型原型array - 数组public static int getStartIndex(int startIndex,
Object[] arrays)
startIndex - 开始下标arrays - 数组信息public static int getEndIndex(int endIndex,
Object[] arrays)
endIndex - 结束下标arrays - 数组信息public static Optional<Object> firstNotNullElem(Object[] objects)
objects - 对象public static Object[] newArray(Object... objects)
objects - 数组public static <K,V> List<K> toList(V[] values, IHandler<? super V,K> keyFunction)
K - k 泛型V - v 泛型values - 遍历对象数组keyFunction - 转换方式public static List toList(Object arrayObject, IHandler keyFunction)
arrayObject - 数组对象keyFunction - 转换方式public static Object[] shift(Object[] array, int offset)
array - 原始数组offset - 偏移量 任意整数。public static int lastIndexOf(char[] chars,
char c,
int startIndex,
int endIndex)
chars - 数组startIndex - 开始位置endIndex - 结束位置c - 字符public static int lastIndexOf(char[] chars,
char c)
chars - 数组c - 字符Copyright © 2024. All rights reserved.