public class ArrayUtil extends Object
| Constructor and Description |
|---|
ArrayUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T[] |
clone(Object[] src,
Class<T> componentType)
returns the clone of
src array. |
static Object[] |
concat(Object[] array1,
Object[] array2)
Returns new array which has all values from array1 and array2 in order.
|
static <T> T[] |
concat(Object[] array1,
Object[] array2,
Class<T> componentType) |
static <T,S extends T> |
contains(T[] array,
S item)
tells whether the
array contains the given item |
static <T> T[] |
copy(Object[] src,
T[] dest)
Copies all elements from
src array to dest array. |
static boolean |
endsWith(Object[] array1,
Object[] array2)
Returns true if
array1 ends with array2 |
static byte[] |
ensureCapacity(byte[] array,
int capacity) |
static char[] |
ensureCapacity(char[] array,
int capacity) |
static boolean |
equals(Object[] array1,
int from1,
Object[] array2,
int from2,
int length)
returns array1[from1, from1+length-1] and array2[from2, from2+length-1] contain same elements
in case of index out of range, returns false
|
static <T> T[] |
filter(T[] array,
Filter<T> filter)
Returns new array which contains only those elements from given
array
which are selected by the filter |
static <T> T |
getFirst(T[] array)
Returns first element in given
array. |
static <T> T |
getLast(T[] array)
Returns last element in given
array. |
static <T,S extends T> |
indexOf(T[] array,
S item)
Returns first index of
item in given array |
static <T,S extends T> |
indexOf(T[] array,
S item,
int fromIndex)
returns first index of
item |
static boolean |
startsWith(Object[] array1,
Object[] array2)
Returns true if
array1 starts with array2 |
static Boolean[] |
toObjectArray(boolean[] arr) |
static Byte[] |
toObjectArray(byte[] arr) |
static Character[] |
toObjectArray(char[] arr) |
static Double[] |
toObjectArray(double[] arr) |
static Float[] |
toObjectArray(float[] arr) |
static Integer[] |
toObjectArray(int[] arr) |
static Long[] |
toObjectArray(long[] arr) |
static Short[] |
toObjectArray(short[] arr) |
public static <T,S extends T> int indexOf(T[] array,
S item,
int fromIndex)
item in given array starting
from fromIndex(inclusive)array - object array, can be nullitem - item to be searched, can be nullfromIndex - index(inclusive) from which search happens.public static <T,S extends T> int indexOf(T[] array,
S item)
item in given arrayarray - object array, can be nullitem - item to be searched, can be nullindexOf(Object[], Object, int)public static <T,S extends T> boolean contains(T[] array,
S item)
array contains the given itemarray - object array, can be nullitem - item to be searched, can be nullpublic static <T> T getFirst(T[] array)
array.
if array is null or of length zero, then returns null
public static <T> T getLast(T[] array)
array.
if array is null or of length zero, then returns null
public static boolean equals(Object[] array1, int from1, Object[] array2, int from2, int length)
public static boolean startsWith(Object[] array1, Object[] array2)
array1 starts with array2public static boolean endsWith(Object[] array1, Object[] array2)
array1 ends with array2public static <T> T[] copy(Object[] src, T[] dest)
src array to dest array.
If dest.length<src.length, it copies only the number of elements
that can fit in dest array.
src - source arraydest - destination arraypublic static <T> T[] clone(Object[] src, Class<T> componentType)
src array.src - source arraycomponentType - the componentType used for the new array createdpublic static <T> T[] filter(T[] array,
Filter<T> filter)
array
which are selected by the filterarray - the array to be filteredfilter - filter to usepublic static Object[] concat(Object[] array1, Object[] array2)
public static Boolean[] toObjectArray(boolean[] arr)
public static Character[] toObjectArray(char[] arr)
public static Byte[] toObjectArray(byte[] arr)
public static Short[] toObjectArray(short[] arr)
public static Integer[] toObjectArray(int[] arr)
public static Long[] toObjectArray(long[] arr)
public static Float[] toObjectArray(float[] arr)
public static Double[] toObjectArray(double[] arr)
public static byte[] ensureCapacity(byte[] array,
int capacity)
public static char[] ensureCapacity(char[] array,
int capacity)
Copyright © 2021. All rights reserved.