@InterfaceAudience.Public @InterfaceStability.Evolving public final class ArrayUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
INDEX_NOT_FOUND
The index value when an element is not found in a list or array:
-1. |
| Modifier and Type | Method and Description |
|---|---|
static <T> boolean |
contains(T objectToFind,
T[] array)
Checks whether the given object to find is in the array.
|
static <T> boolean |
empty(T... array)
Deprecated.
|
static <T> int |
indexOf(T objectToFind,
int startIndex,
T[] array)
Finds the index of the given object in the array starting at the given
index.
|
static <T> int |
indexOf(T objectToFind,
T[] array)
Finds the index of the given object in the array.
|
static <T> boolean |
isEmpty(T... array)
Checks whether the given array is empty.
|
static <T,SizeType> |
length(T... array)
|
static <T> Set<T> |
toSet(T[] indexes)
Converts the array to set of same type.
|
public static final int INDEX_NOT_FOUND
-1. This value is returned by methods in this class and can
also be used in comparisons with values returned by various method from
List.public static <T> boolean contains(T objectToFind,
T[] array)
T - the generic typeobjectToFind - the object to findarray - the arraypublic static <T> int indexOf(T objectToFind,
T[] array)
Finds the index of the given object in the array.
This method returns INDEX_NOT_FOUND (-1) for a
null input array.
T - the generic typeobjectToFind - the object to find, may be nullarray - the array to search through for the object, may be
nullINDEX_NOT_FOUND (-1) if not found or
null array inputpublic static <T> int indexOf(T objectToFind,
int startIndex,
T[] array)
Finds the index of the given object in the array starting at the given index.
This method returns INDEX_NOT_FOUND (-1) for a
null input array.
A negative startIndex is treated as zero. A startIndex larger than the
array length will return INDEX_NOT_FOUND (-1).
T - the generic typeobjectToFind - the object to find, may be nullstartIndex - the index to start searching atarray - the array to search through for the object, may be
nullINDEX_NOT_FOUND (-1) if not found or
null array inputpublic static <T,SizeType> SizeType length(T... array)
T - the generic typeSizeType - the generic typearray - the arrayDouble based on the request.@Deprecated public static <T> boolean empty(T... array)
T - the generic typearray - the aisEmpty(Object...)public static <T> boolean isEmpty(T... array)
T - the generic typearray - the apublic static <T> Set<T> toSet(T[] indexes)
T - the generic typeindexes - the indexesCopyright © 2016 utils4j. All Rights Reserved.