public class ArrayUtil
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static boolean[] |
EMPTY_BOOLEAN_ARRAY |
static byte[] |
EMPTY_BYTE_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 |
| Modifier and Type | Method and Description |
|---|---|
static <T> T[] |
add(T[] array,
T element)
Copies the given array and adds the given element at the end of the new array.
|
static int[] |
toIntArray(java.util.List<java.lang.Integer> ints) |
static java.util.List<java.lang.Integer> |
toIntList(int[] ints) |
static long[] |
toLongArray(java.util.List<java.lang.Long> longs) |
static java.util.List<java.lang.Long> |
toLongList(long[] longs) |
static boolean[] |
toPrimitive(java.lang.Boolean[] array)
Converts an array of object Booleans to primitives.
|
static byte[] |
toPrimitive(java.lang.Byte[] array)
Converts an array of object Bytes to primitives.
|
static double[] |
toPrimitive(java.lang.Double[] array)
Converts an array of object Doubles to primitives.
|
static float[] |
toPrimitive(java.lang.Float[] array)
Converts an array of object Floats to primitives.
|
static int[] |
toPrimitive(java.lang.Integer[] array)
Converts an array of object Integers to primitives.
|
static long[] |
toPrimitive(java.lang.Long[] array)
Converts an array of object Longs to primitives.
|
static short[] |
toPrimitive(java.lang.Short[] array)
Converts an array of object Shorts to primitives.
|
public static final boolean[] EMPTY_BOOLEAN_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 java.util.List<java.lang.Integer> toIntList(int[] ints)
public static int[] toIntArray(java.util.List<java.lang.Integer> ints)
public static java.util.List<java.lang.Long> toLongList(long[] longs)
public static long[] toLongArray(java.util.List<java.lang.Long> longs)
public static boolean[] toPrimitive(java.lang.Boolean[] array)
This method returns null for a null input array.
This code is borrowed from `org.apache.commons:commons-lang3`.
array - a Boolean array, may be nullboolean array, null if null array inputjava.lang.NullPointerException - if array content is nullpublic static byte[] toPrimitive(java.lang.Byte[] array)
This method returns null for a null input array.
This code is borrowed from `org.apache.commons:commons-lang3`.
array - a Byte array, may be nullbyte array, null if null array inputjava.lang.NullPointerException - if array content is nullpublic static short[] toPrimitive(java.lang.Short[] array)
This method returns null for a null input array.
This code is borrowed from `org.apache.commons:commons-lang3`.
array - a Short array, may be nullbyte array, null if null array inputjava.lang.NullPointerException - if array content is nullpublic static int[] toPrimitive(java.lang.Integer[] array)
This method returns null for a null input array.
This code is borrowed from `org.apache.commons:commons-lang3`.
array - a Integer array, may be nullint array, null if null array inputjava.lang.NullPointerException - if array content is nullpublic static long[] toPrimitive(java.lang.Long[] array)
This method returns null for a null input array.
This code is borrowed from `org.apache.commons:commons-lang3`.
array - a Long array, may be nulllong array, null if null array inputjava.lang.NullPointerException - if array content is nullpublic static float[] toPrimitive(java.lang.Float[] array)
This method returns null for a null input array.
This code is borrowed from `org.apache.commons:commons-lang3`.
array - a Float array, may be nullfloat array, null if null array inputjava.lang.NullPointerException - if array content is nullpublic static double[] toPrimitive(java.lang.Double[] array)
This method returns null for a null input array.
This code is borrowed from `org.apache.commons:commons-lang3`.
array - a Double array, may be nulldouble array, null if null array inputjava.lang.NullPointerException - if array content is nullpublic static <T> T[] add(T[] array,
T element)
The new array contains the same elements of the input array plus the given element in the last position. The component type of the new array is the same as that of the input array.
If the input array is null, a new one element array is returned
whose component type is the same as the element, unless the element itself is null,
in which case the return type is Object[]
ArrayUtils.add(null, null) = IllegalArgumentException ArrayUtils.add(null, "a") = ["a"] ArrayUtils.add(["a"], null) = ["a", null] ArrayUtils.add(["a"], "b") = ["a", "b"] ArrayUtils.add(["a", "b"], "c") = ["a", "b", "c"]This code is borrowed from `org.apache.commons:commons-lang3`.
T - the component type of the arrayarray - the array to "add" the element to, may be nullelement - the object to add, may be nulljava.lang.IllegalArgumentException - if both arguments are null