public class ArrayUtils extends Object
Modifier and Type | Field and Description |
---|---|
static boolean[] |
EMPTY_BOOLEAN_ARRAY
An empty boolean array.
|
static byte[] |
EMPTY_BYTE_ARRAY
An empty byte array.
|
static char[] |
EMPTY_CHAR_ARRAY
An empty char array.
|
static double[] |
EMPTY_DOUBLE_ARRAY
An empty double array.
|
static float[] |
EMPTY_FLOAT_ARRAY
An empty float array.
|
static int[] |
EMPTY_INT_ARRAY
An empty int array.
|
static long[] |
EMPTY_LONG_ARRAY
An empty long array.
|
static Object[] |
EMPTY_OBJECT_ARRAY
An empty object array.
|
static short[] |
EMPTY_SHORT_ARRAY
An empty short array.
|
Constructor and Description |
---|
ArrayUtils() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
concat(byte[] a,
byte... b)
Concatenate two byte arrays.
|
static <T> T[] |
concat(T[] a,
T... b)
Concatenate two arrays.
|
static boolean |
isEmpty(Object[] array)
Whether the given array is empty.
|
static boolean |
isNotEmpty(Object[] array)
Whether the given array is not empty.
|
static <T> Iterator<T> |
iterator(T... array)
Produce an iterator for the given array.
|
static <T> Iterator<T> |
reverseIterator(T... array)
Produce an iterator for the given array.
|
static <T> T[] |
toArray(Collection<T> collection,
Class<T> arrayItemClass)
Returns an array containing all of the elements in this collection, using the item class.
|
static <T> T[] |
toArray(Collection<T> collection,
IntFunction<T[]> createArrayFn)
Returns an array containing all of the elements in this collection, using the provided generator function to allocate the returned array.
|
static Object |
toPrimitiveArray(Object[] wrapperArray)
Converts a primitive wrapper array to the equivalent primitive array such as Integer[] to int[].
|
static String |
toString(Object[] array)
Produce a string representation of the given array.
|
static String |
toString(String delimiter,
Object[] array)
Produce a string representation of the given array.
|
static Object[] |
toWrapperArray(Object primitiveArray)
Converts a primitive array to the equivalent wrapper such as int[] to Integer[].
|
public static final Object[] EMPTY_OBJECT_ARRAY
public static final boolean[] EMPTY_BOOLEAN_ARRAY
public static final byte[] EMPTY_BYTE_ARRAY
public static final char[] EMPTY_CHAR_ARRAY
public static final int[] EMPTY_INT_ARRAY
public static final double[] EMPTY_DOUBLE_ARRAY
public static final long[] EMPTY_LONG_ARRAY
public static final float[] EMPTY_FLOAT_ARRAY
public static final short[] EMPTY_SHORT_ARRAY
public static <T> T[] concat(T[] a, T... b)
T
- The array typea
- The first arrayb
- The second arraypublic static byte[] concat(byte[] a, byte... b)
a
- The first arrayb
- The second arraypublic static boolean isEmpty(Object[] array)
array
- The arraypublic static boolean isNotEmpty(Object[] array)
array
- The arraypublic static String toString(@Nullable Object[] array)
array
- The arraypublic static String toString(String delimiter, @Nullable Object[] array)
delimiter
- The delimiterarray
- The arraypublic static <T> Iterator<T> iterator(T... array)
T
- The array typearray
- The arraypublic static <T> Iterator<T> reverseIterator(T... array)
T
- The array typearray
- The arraypublic static <T> T[] toArray(Collection<T> collection, IntFunction<T[]> createArrayFn)
T
- The type of the arraycollection
- The collectioncreateArrayFn
- The function to create the arraypublic static <T> T[] toArray(Collection<T> collection, Class<T> arrayItemClass)
T
- The type of the arraycollection
- The collectionarrayItemClass
- The array item classpublic static Object[] toWrapperArray(Object primitiveArray)
primitiveArray
- The primitive array