public class ArrayUtil extends Object
Modifier and Type | Field and Description |
---|---|
static int |
INDEX_NOT_FOUND
数组中元素未找到的下标,值为-1
|
Constructor and Description |
---|
ArrayUtil() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
addAll(byte[]... arrays) |
static <T> boolean |
contains(T[] array,
T value)
数组中是否包含元素
|
static <T> T[] |
filter(T[] array,
Editor<T> editor)
过滤
过滤过程通过传入的Editor实现来返回需要的元素内容,这个Editor实现可以实现以下功能: |
static <T> T[] |
filter(T[] array,
Filter<T> filter)
过滤
过滤过程通过传入的Filter实现来过滤返回需要的元素内容,这个Editor实现可以实现以下功能: |
static <T> int |
indexOf(T[] array,
Object value)
返回数组中指定元素所在位置,未找到返回
INDEX_NOT_FOUND |
static boolean |
isArray(Object obj)
对象是否为数组对象
|
static String |
join(String[] array,
String conjunction) |
static <T> T[] |
newArray(Class<?> componentType,
int newSize)
新建一个空数组
|
static String |
toString(Object obj) |
public static final int INDEX_NOT_FOUND
public static <T> boolean contains(T[] array, T value)
T
- 数组元素类型array
- 数组value
- 被检查的元素public static <T> int indexOf(T[] array, Object value)
INDEX_NOT_FOUND
T
- 数组类型array
- 数组value
- 被检查的元素INDEX_NOT_FOUND
public static String join(String[] array, String conjunction)
array
- string
- public static boolean isArray(Object obj)
obj
- 对象null
返回falsepublic 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)
1、过滤出需要的对象,Filter.accept(Object)
方法返回true的对象将被加入结果集合中
T
- 数组元素类型array
- 数组filter
- 过滤器接口,用于定义过滤规则public static <T> T[] newArray(Class<?> componentType, int newSize)
T
- 数组元素类型componentType
- 元素类型newSize
- 大小public static byte[] addAll(byte[]... arrays)
Copyright © 2021. All rights reserved.