Top Description Fields Constructors Methods
org.apache.commons.collections4

pack-priv Class ArrayUtils

extends Object
Class Inheritance

Operations on arrays, primitive arrays (like int[]) and primitive wrapper arrays (like Integer[]).

This class tries to handle null input gracefully. An exception will not be thrown for a null array input. However, an Object array that contains a null element may throw an exception. Each method documents its behaviour.

Package private, might move to an internal package if this needs to be public.

#ThreadSafe#

Since
4.2 (Copied from Apache Commons Lang.)

Field Summary

Modifier and TypeField and Description
pack-priv static final int
INDEX_NOT_FOUND

The index value when an element is not found in a list or array: -1.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv static boolean

Returns:

true if the array contains the object
contains
(final Object[]
the array to search through
array
,
final Object
the object to find
objectToFind
)

Checks if the object is in the given array.

pack-priv static <T> int

Returns:

the index of the object within the array, INDEX_NOT_FOUND (-1) if not found or null array input
indexOf
(final T[]
the array to search through for the object, may be null
array
,
final Object
the object to find, may be null
objectToFind
)

Finds the index of the given object in the array.

pack-priv static int

Returns:

the index of the object within the array starting at the index, INDEX_NOT_FOUND (-1) if not found or null array input
indexOf
(final Object[]
the array to search through for the object, may be null
array
,
final Object
the object to find, may be null
objectToFind
,
int
the index to start searching at
startIndex
)

Finds the index of the given object in the array starting at the given index.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INDEX_NOT_FOUNDback to summary
pack-priv static final int INDEX_NOT_FOUND

The index value when an element is not found in a list or array: -1. This value is returned by methods in this class and can also be used in comparisons with values returned by various method from java.util.List.

Constructor Detail

ArrayUtilsback to summary
pack-priv ArrayUtils()

Method Detail

containsback to summary
pack-priv static boolean contains(final Object[] array, final Object objectToFind)

Checks if the object is in the given array.

The method returns false if a null array is passed in.

Parameters
array:Object[]

the array to search through

objectToFind:Object

the object to find

Returns:boolean

true if the array contains the object

indexOfback to summary
pack-priv static <T> int indexOf(final T[] array, final Object objectToFind)

Finds the index of the given object in the array.

This method returns INDEX_NOT_FOUND (-1) for a null input array.

Parameters
array:T[]

the array to search through for the object, may be null

objectToFind:Object

the object to find, may be null

Returns:int

the index of the object within the array, INDEX_NOT_FOUND (-1) if not found or null array input

indexOfback to summary
pack-priv static int indexOf(final Object[] array, final Object objectToFind, int startIndex)

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).

Parameters
array:Object[]

the array to search through for the object, may be null

objectToFind:Object

the object to find, may be null

startIndex:int

the index to start searching at

Returns:int

the index of the object within the array starting at the index, INDEX_NOT_FOUND (-1) if not found or null array input