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

public Class ArrayUtils

extends Object
Class Inheritance
Imports
java.lang.reflect.Array, .Field, .Method, .Type, java.security.SecureRandom, java.util.Arrays, .BitSet, .Comparator, .Date, .HashMap, .Map, .Objects, .Random, java.util.concurrent.ThreadLocalRandom, java.util.function.Function, .IntFunction, .Supplier, org.apache.commons.lang3.builder.EqualsBuilder, .HashCodeBuilder, .ToStringBuilder, .ToStringStyle, org.apache.commons.lang3.function.FailableFunction, org.apache.commons.lang3.mutable.MutableInt, org.apache.commons.lang3.stream.IntStreams, .Streams

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

#ThreadSafe#

Since
2.0

Field Summary

Modifier and TypeField and Description
public static final boolean[]
EMPTY_BOOLEAN_ARRAY

An empty immutable boolean array.

public static final Boolean[]
EMPTY_BOOLEAN_OBJECT_ARRAY

An empty immutable Boolean array.

public static final byte[]
EMPTY_BYTE_ARRAY

An empty immutable byte array.

public static final Byte[]
EMPTY_BYTE_OBJECT_ARRAY

An empty immutable Byte array.

public static final char[]
EMPTY_CHAR_ARRAY

An empty immutable char array.

public static final Character[]
EMPTY_CHARACTER_OBJECT_ARRAY

An empty immutable Character array.

public static final Class<?>[]
EMPTY_CLASS_ARRAY

An empty immutable Class array.

public static final double[]
EMPTY_DOUBLE_ARRAY

An empty immutable double array.

public static final Double[]
EMPTY_DOUBLE_OBJECT_ARRAY

An empty immutable Double array.

public static final Field[]
EMPTY_FIELD_ARRAY

An empty immutable Field array.

public static final float[]
EMPTY_FLOAT_ARRAY

An empty immutable float array.

public static final Float[]
EMPTY_FLOAT_OBJECT_ARRAY

An empty immutable Float array.

public static final int[]
EMPTY_INT_ARRAY

An empty immutable int array.

public static final Integer[]
EMPTY_INTEGER_OBJECT_ARRAY

An empty immutable Integer array.

public static final long[]
EMPTY_LONG_ARRAY

An empty immutable long array.

public static final Long[]
EMPTY_LONG_OBJECT_ARRAY

An empty immutable Long array.

public static final Method[]
EMPTY_METHOD_ARRAY

An empty immutable Method array.

public static final Object[]
EMPTY_OBJECT_ARRAY

An empty immutable Object array.

public static final short[]
EMPTY_SHORT_ARRAY

An empty immutable short array.

public static final Short[]
EMPTY_SHORT_OBJECT_ARRAY

An empty immutable Short array.

public static final String[]
EMPTY_STRING_ARRAY

An empty immutable String array.

public static final Throwable[]
EMPTY_THROWABLE_ARRAY

An empty immutable Throwable array.

public static final Type[]
EMPTY_TYPE_ARRAY

An empty immutable Type array.

public static final int
INDEX_NOT_FOUND

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

public static int
SOFT_MAX_ARRAY_LENGTH

The SOFT_MAX_ARRAY_LENGTH constant from Java's internal ArraySupport class.

Constructor Summary

AccessConstructor and Description
public
ArrayUtils()
Deprecated TODO Make private in 4.0.

ArrayUtils instances should NOT be constructed in standard programming.

Method Summary

Modifier and TypeMethod and Description
public static boolean[]

Returns:

A new array containing the existing elements plus the new element
add
(final boolean[]
the array to copy and add the element to, may be null
array
,
final boolean
the object to add at the last index of the new array
element
)

Copies the given array and adds the given element at the end of the new array.

public static boolean[]

Returns:

A new array containing the existing elements and the new element
add
(final boolean[]
the array to add the element to, may be null
array
,
final int
the position of the new object
index
,
final boolean
the object to add
element
)
Deprecated this method has been superseded by insert(int, boolean[], boolean...) and may be removed in a future release.

Inserts the specified element at the specified position in the array.

public static byte[]

Returns:

A new array containing the existing elements plus the new element
add
(final byte[]
the array to copy and add the element to, may be null
array
,
final byte
the object to add at the last index of the new array
element
)

Copies the given array and adds the given element at the end of the new array.

public static byte[]

Returns:

A new array containing the existing elements and the new element
add
(final byte[]
the array to add the element to, may be null
array
,
final int
the position of the new object
index
,
final byte
the object to add
element
)
Deprecated this method has been superseded by insert(int, byte[], byte...) and may be removed in a future release.

Inserts the specified element at the specified position in the array.

public static char[]

Returns:

A new array containing the existing elements plus the new element
add
(final char[]
the array to copy and add the element to, may be null
array
,
final char
the object to add at the last index of the new array
element
)

Copies the given array and adds the given element at the end of the new array.

public static char[]

Returns:

A new array containing the existing elements and the new element
add
(final char[]
the array to add the element to, may be null
array
,
final int
the position of the new object
index
,
final char
the object to add
element
)
Deprecated this method has been superseded by insert(int, char[], char...) and may be removed in a future release.

Inserts the specified element at the specified position in the array.

public static double[]

Returns:

A new array containing the existing elements plus the new element
add
(final double[]
the array to copy and add the element to, may be null
array
,
final double
the object to add at the last index of the new array
element
)

Copies the given array and adds the given element at the end of the new array.

public static double[]

Returns:

A new array containing the existing elements and the new element
add
(final double[]
the array to add the element to, may be null
array
,
final int
the position of the new object
index
,
final double
the object to add
element
)
Deprecated this method has been superseded by insert(int, double[], double...) and may be removed in a future release.

Inserts the specified element at the specified position in the array.

public static float[]

Returns:

A new array containing the existing elements plus the new element
add
(final float[]
the array to copy and add the element to, may be null
array
,
final float
the object to add at the last index of the new array
element
)

Copies the given array and adds the given element at the end of the new array.

public static float[]

Returns:

A new array containing the existing elements and the new element
add
(final float[]
the array to add the element to, may be null
array
,
final int
the position of the new object
index
,
final float
the object to add
element
)
Deprecated this method has been superseded by insert(int, float[], float...) and may be removed in a future release.

Inserts the specified element at the specified position in the array.

public static int[]

Returns:

A new array containing the existing elements plus the new element
add
(final int[]
the array to copy and add the element to, may be null
array
,
final int
the object to add at the last index of the new array
element
)

Copies the given array and adds the given element at the end of the new array.

public static int[]

Returns:

A new array containing the existing elements and the new element
add
(final int[]
the array to add the element to, may be null
array
,
final int
the position of the new object
index
,
final int
the object to add
element
)
Deprecated this method has been superseded by insert(int, int[], int...) and may be removed in a future release.

Inserts the specified element at the specified position in the array.

public static long[]

Returns:

A new array containing the existing elements and the new element
add
(final long[]
the array to add the element to, may be null
array
,
final int
the position of the new object
index
,
final long
the object to add
element
)
Deprecated this method has been superseded by insert(int, long[], long...) and may be removed in a future release.

Inserts the specified element at the specified position in the array.

public static long[]

Returns:

A new array containing the existing elements plus the new element
add
(final long[]
the array to copy and add the element to, may be null
array
,
final long
the object to add at the last index of the new array
element
)

Copies the given array and adds the given element at the end of the new array.

private static Object

Returns:

A new array containing the existing elements and the new element
add
(final Object
the array to add the element to, may be null
array
,
final int
the position of the new object
index
,
final Object
the object to add
element
,
final Class<?>
the type of the element being added
clazz
)

Underlying implementation of add(array, index, element) methods.

public static short[]

Returns:

A new array containing the existing elements and the new element
add
(final short[]
the array to add the element to, may be null
array
,
final int
the position of the new object
index
,
final short
the object to add
element
)
Deprecated this method has been superseded by insert(int, short[], short...) and may be removed in a future release.

Inserts the specified element at the specified position in the array.

public static short[]

Returns:

A new array containing the existing elements plus the new element
add
(final short[]
the array to copy and add the element to, may be null
array
,
final short
the object to add at the last index of the new array
element
)

Copies the given array and adds the given element at the end of the new array.

public static <
the component type of the array
T
>
T[]

Returns:

A new array containing the existing elements and the new element
add
(final T[]
the array to add the element to, may be null
array
,
final int
the position of the new object
index
,
final T
the object to add
element
)
Deprecated this method has been superseded by insert(int, T[], T...) and may be removed in a future release.

Inserts the specified element at the specified position in the array.

public static <
the component type of the array
T
>
T[]

Returns:

A new array containing the existing elements plus the new element The returned array type will be that of the input array (unless null), in which case it will have the same type as the element. If both are null, an IllegalArgumentException is thrown
add
(final T[]
the array to "add" the element to, may be null
array
,
final T
the object to add, may be null
element
)

Copies the given array and adds the given element at the end of the new array.

public static boolean[]

Returns:

The new boolean[] array or null.
addAll
(final boolean[]
the first array whose elements are added to the new array.
array1
,
final boolean...
the second array whose elements are added to the new array.
array2
)

Adds all the elements of the given arrays into a new array.

public static byte[]

Returns:

The new byte[] array or null.
addAll
(final byte[]
the first array whose elements are added to the new array.
array1
,
final byte...
the second array whose elements are added to the new array.
array2
)

Adds all the elements of the given arrays into a new array.

public static char[]

Returns:

The new char[] array or null.
addAll
(final char[]
the first array whose elements are added to the new array.
array1
,
final char...
the second array whose elements are added to the new array.
array2
)

Adds all the elements of the given arrays into a new array.

public static double[]

Returns:

The new double[] array or null.
addAll
(final double[]
the first array whose elements are added to the new array.
array1
,
final double...
the second array whose elements are added to the new array.
array2
)

Adds all the elements of the given arrays into a new array.

public static float[]

Returns:

The new float[] array or null.
addAll
(final float[]
the first array whose elements are added to the new array.
array1
,
final float...
the second array whose elements are added to the new array.
array2
)

Adds all the elements of the given arrays into a new array.

public static int[]

Returns:

The new int[] array or null.
addAll
(final int[]
the first array whose elements are added to the new array.
array1
,
final int...
the second array whose elements are added to the new array.
array2
)

Adds all the elements of the given arrays into a new array.

public static long[]

Returns:

The new long[] array or null.
addAll
(final long[]
the first array whose elements are added to the new array.
array1
,
final long...
the second array whose elements are added to the new array.
array2
)

Adds all the elements of the given arrays into a new array.

public static short[]

Returns:

The new short[] array or null.
addAll
(final short[]
the first array whose elements are added to the new array.
array1
,
final short...
the second array whose elements are added to the new array.
array2
)

Adds all the elements of the given arrays into a new array.

public static <
the component type of the array
T
>
T[]

Returns:

The new array, null if both arrays are null. The type of the new array is the type of the first array, unless the first array is null, in which case the type is the same as the second array.
addAll
(final T[]
the first array whose elements are added to the new array, may be null
array1
,
final T...
the second array whose elements are added to the new array, may be null
array2
)

Adds all the elements of the given arrays into a new array.

public static boolean[]

Returns:

A new array containing the existing elements plus the new element The returned array type will be that of the input array (unless null), in which case it will have the same type as the element.
addFirst
(final boolean[]
the array to "add" the element to, may be null.
array
,
final boolean
the object to add.
element
)

Copies the given array and adds the given element at the beginning of the new array.

public static byte[]

Returns:

A new array containing the existing elements plus the new element The returned array type will be that of the input array (unless null), in which case it will have the same type as the element.
addFirst
(final byte[]
the array to "add" the element to, may be null.
array
,
final byte
the object to add.
element
)

Copies the given array and adds the given element at the beginning of the new array.

public static char[]

Returns:

A new array containing the existing elements plus the new element The returned array type will be that of the input array (unless null), in which case it will have the same type as the element.
addFirst
(final char[]
the array to "add" the element to, may be null.
array
,
final char
the object to add.
element
)

Copies the given array and adds the given element at the beginning of the new array.

public static double[]

Returns:

A new array containing the existing elements plus the new element The returned array type will be that of the input array (unless null), in which case it will have the same type as the element.
addFirst
(final double[]
the array to "add" the element to, may be null.
array
,
final double
the object to add.
element
)

Copies the given array and adds the given element at the beginning of the new array.

public static float[]

Returns:

A new array containing the existing elements plus the new element The returned array type will be that of the input array (unless null), in which case it will have the same type as the element.
addFirst
(final float[]
the array to "add" the element to, may be null.
array
,
final float
the object to add.
element
)

Copies the given array and adds the given element at the beginning of the new array.

public static int[]

Returns:

A new array containing the existing elements plus the new element The returned array type will be that of the input array (unless null), in which case it will have the same type as the element.
addFirst
(final int[]
the array to "add" the element to, may be null.
array
,
final int
the object to add.
element
)

Copies the given array and adds the given element at the beginning of the new array.

public static long[]

Returns:

A new array containing the existing elements plus the new element The returned array type will be that of the input array (unless null), in which case it will have the same type as the element.
addFirst
(final long[]
the array to "add" the element to, may be null.
array
,
final long
the object to add.
element
)

Copies the given array and adds the given element at the beginning of the new array.

public static short[]

Returns:

A new array containing the existing elements plus the new element The returned array type will be that of the input array (unless null), in which case it will have the same type as the element.
addFirst
(final short[]
the array to "add" the element to, may be null.
array
,
final short
the object to add.
element
)

Copies the given array and adds the given element at the beginning of the new array.

public static <
the component type of the array
T
>
T[]

Returns:

A new array containing the existing elements plus the new element The returned array type will be that of the input array (unless null), in which case it will have the same type as the element. If both are null, an IllegalArgumentException is thrown
addFirst
(final T[]
the array to "add" the element to, may be null
array
,
final T
the object to add, may be null
element
)

Copies the given array and adds the given element at the beginning of the new array.

public static <
the type.
T
>
T

Returns:

dest
arraycopy
(final T
the source array.
source
,
final int
starting position in the source array.
sourcePos
,
final int
starting position in the destination data.
destPos
,
final int
the number of array elements to be copied.
length
,
final Function<Integer, T>
allocates the array to populate and return.
allocator
)

A fluent version of System#arraycopy(Object, int, Object, int, int) that returns the destination array.

public static <
the type.
T
>
T

Returns:

dest
arraycopy
(final T
the source array.
source
,
final int
starting position in the source array.
sourcePos
,
final int
starting position in the destination data.
destPos
,
final int
the number of array elements to be copied.
length
,
final Supplier<T>
allocates the array to populate and return.
allocator
)

A fluent version of System#arraycopy(Object, int, Object, int, int) that returns the destination array.

public static <
the type
T
>
T

Returns:

dest
arraycopy
(final T
the source array.
source
,
final int
starting position in the source array.
sourcePos
,
final T
the destination array.
dest
,
final int
starting position in the destination data.
destPos
,
final int
the number of array elements to be copied.
length
)

A fluent version of System#arraycopy(Object, int, Object, int, int) that returns the destination array.

public static boolean[]

Returns:

the cloned array, null if null input
clone
(final boolean[]
the array to clone, may be null
array
)

Clones an array or returns null.

public static byte[]

Returns:

the cloned array, null if null input
clone
(final byte[]
the array to clone, may be null
array
)

Clones an array or returns null.

public static char[]

Returns:

the cloned array, null if null input
clone
(final char[]
the array to clone, may be null
array
)

Clones an array or returns null.

public static double[]

Returns:

the cloned array, null if null input
clone
(final double[]
the array to clone, may be null
array
)

Clones an array or returns null.

public static float[]

Returns:

the cloned array, null if null input
clone
(final float[]
the array to clone, may be null
array
)

Clones an array or returns null.

public static int[]

Returns:

the cloned array, null if null input
clone
(final int[]
the array to clone, may be null
array
)

Clones an array or returns null.

public static long[]

Returns:

the cloned array, null if null input
clone
(final long[]
the array to clone, may be null
array
)

Clones an array or returns null.

public static short[]

Returns:

the cloned array, null if null input
clone
(final short[]
the array to clone, may be null
array
)

Clones an array or returns null.

public static <
the component type of the array
T
>
T[]

Returns:

the cloned array, null if null input
clone
(final T[]
the array to shallow clone, may be null
array
)

Shallow clones an array or returns null.

public static boolean

Returns:

true if the array contains the object
contains
(final boolean[]
the array to search
array
,
final boolean
the value to find
valueToFind
)

Checks if the value is in the given array.

public static boolean

Returns:

true if the array contains the object
contains
(final byte[]
the array to search
array
,
final byte
the value to find
valueToFind
)

Checks if the value is in the given array.

public static boolean

Returns:

true if the array contains the object
contains
(final char[]
the array to search
array
,
final char
the value to find
valueToFind
)

Checks if the value is in the given array.

public static boolean

Returns:

true if the array contains the object
contains
(final double[]
the array to search
array
,
final double
the value to find
valueToFind
)

Checks if the value is in the given array.

public static boolean

Returns:

true if value falling within tolerance is in array
contains
(final double[]
the array to search
array
,
final double
the value to find
valueToFind
,
final double
the array contains the tolerance of the search
tolerance
)

Checks if a value falling within the given tolerance is in the given array.

public static boolean

Returns:

true if the array contains the object
contains
(final float[]
the array to search
array
,
final float
the value to find
valueToFind
)

Checks if the value is in the given array.

public static boolean

Returns:

true if the array contains the object
contains
(final int[]
the array to search
array
,
final int
the value to find
valueToFind
)

Checks if the value is in the given array.

public static boolean

Returns:

true if the array contains the object
contains
(final long[]
the array to search
array
,
final long
the value to find
valueToFind
)

Checks if the value is in the given array.

public static boolean

Returns:

true if the array contains the object
contains
(final Object[]
the array to search, may be null.
array
,
final Object
the object to find, may be null.
objectToFind
)

Checks if the object is in the given array.

public static boolean

Returns:

true if the array contains the object
contains
(final short[]
the array to search
array
,
final short
the value to find
valueToFind
)

Checks if the value is in the given array.

public static boolean

Returns:

true if the array contains any of the ints
containsAny
(final int[]
the array to search
array
,
final int...
any of the ints to find
objectsToFind
)

Checks if any of the ints are in the given array.

public static boolean

Returns:

true if the array contains any of the objects
containsAny
(final Object[]
the array to search, may be null.
array
,
final Object...
any of the objects to find, may be null.
objectsToFind
)

Checks if any of the objects are in the given array.

private static Object

Returns:

A new copy of the array of size 1 greater than the input.
copyArrayGrow1
(final Object
The array to copy, must not be null.
array
,
final Class<?>
If array is null, create a size 1 array of this type.
newArrayComponentType
)

Returns a copy of the given array of size 1 greater than the argument.

public static <
The type of array elements.
T
>
T

Returns:

the nTh element of an array or null if the index is out of bounds or the array is null.
get
(final T[]
The array to index.
array
,
final int
The index
index
)

Gets the nTh element of an array or null if the index is out of bounds or the array is null.

public static <
The type of array elements.
T
>
T

Returns:

the nTh element of an array or a default value if the index is out of bounds.
get
(final T[]
The array to index.
array
,
final int
The index
index
,
final T
The return value of the given index is out of bounds.
defaultValue
)

Gets the nTh element of an array or a default value if the index is out of bounds.

public static <
The array type.
T
>
Class<T>

Returns:

The component type.
getComponentType
(final T[]
The array.
array
)

Gets an array's component type.

public static int

Returns:

The length of the array, or 0 if the array is null
getLength
(final Object
the array to retrieve the length from, may be null.
array
)

Gets the length of the specified array.

public static int

Returns:

a hash code for the array
hashCode
(final Object
the array to get a hash code for, null returns zero
array
)

Gets a hash code for an array handling multidimensional arrays correctly.

pack-priv static <K> void
increment(final Map<K, MutableInt> occurrences, final K boxed)

public static BitSet

Returns:

a BitSet of all the indices of the value within the array, an empty BitSet if not found or null array input
indexesOf
(final boolean[]
the array to search for the object, may be null
array
,
final boolean
the value to find
valueToFind
)

Finds the indices of the given value in the array.

public static BitSet

Returns:

a BitSet of all the indices of the value within the array, an empty BitSet if not found or null array input
indexesOf
(final boolean[]
the array to search for the object, may be null
array
,
final boolean
the value to find
valueToFind
,
int
the index to start searching at
startIndex
)

Finds the indices of the given value in the array starting at the given index.

public static BitSet

Returns:

a BitSet of all the indices of the value within the array, an empty BitSet if not found or null array input
indexesOf
(final byte[]
the array to search for the object, may be null
array
,
final byte
the value to find
valueToFind
)

Finds the indices of the given value in the array.

public static BitSet

Returns:

a BitSet of all the indices of the value within the array, an empty BitSet if not found or null array input
indexesOf
(final byte[]
the array to search for the object, may be null
array
,
final byte
the value to find
valueToFind
,
int
the index to start searching at
startIndex
)

Finds the indices of the given value in the array starting at the given index.

public static BitSet

Returns:

a BitSet of all the indices of the value within the array, an empty BitSet if not found or null array input
indexesOf
(final char[]
the array to search for the object, may be null
array
,
final char
the value to find
valueToFind
)

Finds the indices of the given value in the array.

public static BitSet

Returns:

a BitSet of all the indices of the value within the array, an empty BitSet if not found or null array input
indexesOf
(final char[]
the array to search for the object, may be null
array
,
final char
the value to find
valueToFind
,
int
the index to start searching at
startIndex
)

Finds the indices of the given value in the array starting at the given index.

public static BitSet

Returns:

a BitSet of all the indices of the value within the array, an empty BitSet if not found or null array input
indexesOf
(final double[]
the array to search for the object, may be null
array
,
final double
the value to find
valueToFind
)

Finds the indices of the given value in the array.

public static BitSet

Returns:

a BitSet of all the indices of the value within the array, an empty BitSet if not found or null array input
indexesOf
(final double[]
the array to search for the object, may be null
array
,
final double
the value to find
valueToFind
,
final double
tolerance of the search
tolerance
)

Finds the indices of the given value within a given tolerance in the array.

public static BitSet

Returns:

a BitSet of the indices of the value within the array, an empty BitSet if not found or null array input
indexesOf
(final double[]
the array to search for the object, may be null
array
,
final double
the value to find
valueToFind
,
int
the index to start searching at
startIndex
)

Finds the indices of the given value in the array starting at the given index.

public static BitSet

Returns:

a BitSet of the indices of the value within the array, an empty BitSet if not found or null array input
indexesOf
(final double[]
the array to search for the object, may be null
array
,
final double
the value to find
valueToFind
,
int
the index to start searching at
startIndex
,
final double
tolerance of the search
tolerance
)

Finds the indices of the given value in the array starting at the given index.

public static BitSet

Returns:

a BitSet of all the indices of the value within the array, an empty BitSet if not found or null array input
indexesOf
(final float[]
the array to search for the object, may be null
array
,
final float
the value to find
valueToFind
)

Finds the indices of the given value in the array.

public static BitSet

Returns:

a BitSet of all the indices of the value within the array, an empty BitSet if not found or null array input
indexesOf
(final float[]
the array to search for the object, may be null
array
,
final float
the value to find
valueToFind
,
int
the index to start searching at
startIndex
)

Finds the indices of the given value in the array starting at the given index.

public static BitSet

Returns:

a BitSet of all the indices of the value within the array, an empty BitSet if not found or null array input
indexesOf
(final int[]
the array to search for the object, may be null
array
,
final int
the value to find
valueToFind
)

Finds the indices of the given value in the array.

public static BitSet

Returns:

a BitSet of all the indices of the value within the array, an empty BitSet if not found or null array input
indexesOf
(final int[]
the array to search for the object, may be null
array
,
final int
the value to find
valueToFind
,
int
the index to start searching at
startIndex
)

Finds the indices of the given value in the array starting at the given index.

public static BitSet

Returns:

a BitSet of all the indices of the value within the array, an empty BitSet if not found or null array input
indexesOf
(final long[]
the array to search for the object, may be null
array
,
final long
the value to find
valueToFind
)

Finds the indices of the given value in the array.

public static BitSet

Returns:

a BitSet of all the indices of the value within the array, an empty BitSet if not found or null array input
indexesOf
(final long[]
the array to search for the object, may be null
array
,
final long
the value to find
valueToFind
,
int
the index to start searching at
startIndex
)

Finds the indices of the given value in the array starting at the given index.

public static BitSet

Returns:

a BitSet of all the indices of the object within the array, an empty BitSet if not found or null array input
indexesOf
(final Object[]
the array to search for the object, may be null.
array
,
final Object
the object to find, may be null.
objectToFind
)

Finds the indices of the given object in the array.

public static BitSet

Returns:

a BitSet of all the indices of the object within the array starting at the index, an empty BitSet if not found or null array input
indexesOf
(final Object[]
the array to search 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 indices of the given object in the array starting at the given index.

public static BitSet

Returns:

a BitSet of all the indices of the value within the array, an empty BitSet if not found or null array input
indexesOf
(final short[]
the array to search for the object, may be null
array
,
final short
the value to find
valueToFind
)

Finds the indices of the given value in the array.

public static BitSet

Returns:

a BitSet of all the indices of the value within the array, an empty BitSet if not found or null array input
indexesOf
(final short[]
the array to search for the object, may be null
array
,
final short
the value to find
valueToFind
,
int
the index to start searching at
startIndex
)

Finds the indices of the given value in the array starting at the given index.

public static int

Returns:

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

Finds the index of the given value in the array.

public static int

Returns:

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

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

public static int

Returns:

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

Finds the index of the given value in the array.

public static int

Returns:

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

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

public static int

Returns:

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

Finds the index of the given value in the array.

public static int

Returns:

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

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

public static int

Returns:

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

Finds the index of the given value in the array.

public static int

Returns:

the index of the value within the array, INDEX_NOT_FOUND (-1) if not found or null array input
indexOf
(final double[]
the array to search for the object, may be null
array
,
final double
the value to find
valueToFind
,
final double
tolerance of the search
tolerance
)

Finds the index of the given value within a given tolerance in the array.

public static int

Returns:

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

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

public static int

Returns:

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

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

public static int

Returns:

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

Finds the index of the given value in the array.

public static int

Returns:

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

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

public static int

Returns:

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

Finds the index of the given value in the array.

public static int

Returns:

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

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

public static int

Returns:

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

Finds the index of the given value in the array.

public static int

Returns:

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

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

public static int

Returns:

the index of the object within the array, INDEX_NOT_FOUND (-1) if not found or null array input
indexOf
(final Object[]
the array to search 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.

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

public static int

Returns:

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

Finds the index of the given value in the array.

public static int

Returns:

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

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

public static boolean[]

Returns:

The new array or null if the given array is null.
insert
(final int
the position within array to insert the new values
index
,
final boolean[]
the array to insert the values into, may be null
array
,
final boolean...
the new values to insert, may be null
values
)

Inserts elements into an array at the given index (starting from zero).

public static byte[]

Returns:

The new array or null if the given array is null.
insert
(final int
the position within array to insert the new values
index
,
final byte[]
the array to insert the values into, may be null
array
,
final byte...
the new values to insert, may be null
values
)

Inserts elements into an array at the given index (starting from zero).

public static char[]

Returns:

The new array or null if the given array is null.
insert
(final int
the position within array to insert the new values
index
,
final char[]
the array to insert the values into, may be null
array
,
final char...
the new values to insert, may be null
values
)

Inserts elements into an array at the given index (starting from zero).

public static double[]

Returns:

The new array or null if the given array is null.
insert
(final int
the position within array to insert the new values
index
,
final double[]
the array to insert the values into, may be null
array
,
final double...
the new values to insert, may be null
values
)

Inserts elements into an array at the given index (starting from zero).

public static float[]

Returns:

The new array or null if the given array is null.
insert
(final int
the position within array to insert the new values
index
,
final float[]
the array to insert the values into, may be null
array
,
final float...
the new values to insert, may be null
values
)

Inserts elements into an array at the given index (starting from zero).

public static int[]

Returns:

The new array or null if the given array is null.
insert
(final int
the position within array to insert the new values
index
,
final int[]
the array to insert the values into, may be null
array
,
final int...
the new values to insert, may be null
values
)

Inserts elements into an array at the given index (starting from zero).

public static long[]

Returns:

The new array or null if the given array is null.
insert
(final int
the position within array to insert the new values
index
,
final long[]
the array to insert the values into, may be null
array
,
final long...
the new values to insert, may be null
values
)

Inserts elements into an array at the given index (starting from zero).

public static short[]

Returns:

The new array or null if the given array is null.
insert
(final int
the position within array to insert the new values
index
,
final short[]
the array to insert the values into, may be null
array
,
final short...
the new values to insert, may be null
values
)

Inserts elements into an array at the given index (starting from zero).

public static <
The type of elements in array and values
T
>
T[]

Returns:

The new array or null if the given array is null.
insert
(final int
the position within array to insert the new values
index
,
final T[]
the array to insert the values into, may be null
array
,
final T...
the new values to insert, may be null
values
)

Inserts elements into an array at the given index (starting from zero).

private static boolean

Returns:

true if the array is empty or null
isArrayEmpty
(final Object
the array to test
array
)

Checks if an array is empty or null.

public static <
the component type of the array
T
>
boolean

Returns:

Whether the given index is safely-accessible in the given array
isArrayIndexValid
(final T[]
the array to inspect, may be null.
array
,
final int
the index of the array to be inspected
index
)

Tests whether a given array can safely be accessed at the given index.

public static boolean

Returns:

true if the array is empty or null
isEmpty
(final boolean[]
the array to test
array
)

Tests whether an array of primitive booleans is empty or null.

public static boolean

Returns:

true if the array is empty or null
isEmpty
(final byte[]
the array to test
array
)

Tests whether an array of primitive bytes is empty or null.

public static boolean

Returns:

true if the array is empty or null
isEmpty
(final char[]
the array to test
array
)

Tests whether an array of primitive chars is empty or null.

public static boolean

Returns:

true if the array is empty or null
isEmpty
(final double[]
the array to test
array
)

Tests whether an array of primitive doubles is empty or null.

public static boolean

Returns:

true if the array is empty or null
isEmpty
(final float[]
the array to test
array
)

Tests whether an array of primitive floats is empty or null.

public static boolean

Returns:

true if the array is empty or null
isEmpty
(final int[]
the array to test
array
)

Tests whether an array of primitive ints is empty or null.

public static boolean

Returns:

true if the array is empty or null
isEmpty
(final long[]
the array to test
array
)

Tests whether an array of primitive longs is empty or null.

public static boolean

Returns:

true if the array is empty or null
isEmpty
(final Object[]
the array to test
array
)

Tests whether an array of Objects is empty or null.

public static boolean

Returns:

true if the array is empty or null
isEmpty
(final short[]
the array to test
array
)

Tests whether an array of primitive shorts is empty or null.

public static boolean

Returns:

true if the arrays are equal
isEquals
(final Object
the left-hand side array to compare, may be null
array1
,
final Object
the right-hand side array to compare, may be null
array2
)
Deprecated this method has been replaced by java.util.Objects.deepEquals(Object, Object) and will be removed from future releases.

Tests whether two arrays have equal content, using equals(), handling multidimensional arrays correctly.

public static boolean

Returns:

true if the array is not empty and not null
isNotEmpty
(final boolean[]
the array to test
array
)

Tests whether an array of primitive booleans is not empty and not null.

public static boolean

Returns:

true if the array is not empty and not null
isNotEmpty
(final byte[]
the array to test
array
)

Tests whether an array of primitive bytes is not empty and not null.

public static boolean

Returns:

true if the array is not empty and not null
isNotEmpty
(final char[]
the array to test
array
)

Tests whether an array of primitive chars is not empty and not null.

public static boolean

Returns:

true if the array is not empty and not null
isNotEmpty
(final double[]
the array to test
array
)

Tests whether an array of primitive doubles is not empty and not null.

public static boolean

Returns:

true if the array is not empty and not null
isNotEmpty
(final float[]
the array to test
array
)

Tests whether an array of primitive floats is not empty and not null.

public static boolean

Returns:

true if the array is not empty and not null
isNotEmpty
(final int[]
the array to test
array
)

Tests whether an array of primitive ints is not empty and not null.

public static boolean

Returns:

true if the array is not empty and not null
isNotEmpty
(final long[]
the array to test
array
)

Tests whether an array of primitive longs is not empty and not null.

public static boolean

Returns:

true if the array is not empty and not null
isNotEmpty
(final short[]
the array to test
array
)

Tests whether an array of primitive shorts is not empty and not null.

public static <
the component type of the array
T
>
boolean

Returns:

true if the array is not empty and not null
isNotEmpty
(final T[]
the array to test
array
)

Tests whether an array of Objects is not empty and not null.

public static boolean

Returns:

true if length of arrays matches, treating null as an empty array
isSameLength
(final boolean[]
the first array, may be null
array1
,
final boolean[]
the second array, may be null
array2
)

Tests whether two arrays are the same length, treating null arrays as length 0.

public static boolean

Returns:

true if length of arrays matches, treating null as an empty array
isSameLength
(final byte[]
the first array, may be null
array1
,
final byte[]
the second array, may be null
array2
)

Tests whether two arrays are the same length, treating null arrays as length 0.

public static boolean

Returns:

true if length of arrays matches, treating null as an empty array
isSameLength
(final char[]
the first array, may be null
array1
,
final char[]
the second array, may be null
array2
)

Tests whether two arrays are the same length, treating null arrays as length 0.

public static boolean

Returns:

true if length of arrays matches, treating null as an empty array
isSameLength
(final double[]
the first array, may be null
array1
,
final double[]
the second array, may be null
array2
)

Tests whether two arrays are the same length, treating null arrays as length 0.

public static boolean

Returns:

true if length of arrays matches, treating null as an empty array
isSameLength
(final float[]
the first array, may be null
array1
,
final float[]
the second array, may be null
array2
)

Tests whether two arrays are the same length, treating null arrays as length 0.

public static boolean

Returns:

true if length of arrays matches, treating null as an empty array
isSameLength
(final int[]
the first array, may be null
array1
,
final int[]
the second array, may be null
array2
)

Tests whether two arrays are the same length, treating null arrays as length 0.

public static boolean

Returns:

true if length of arrays matches, treating null as an empty array
isSameLength
(final long[]
the first array, may be null
array1
,
final long[]
the second array, may be null
array2
)

Tests whether two arrays are the same length, treating null arrays as length 0.

public static boolean

Returns:

true if length of arrays matches, treating null as an empty array
isSameLength
(final Object
the first array, may be null
array1
,
final Object
the second array, may be null
array2
)

Tests whether two arrays are the same length, treating null arrays as length 0.

public static boolean

Returns:

true if length of arrays matches, treating null as an empty array
isSameLength
(final Object[]
the first array, may be null
array1
,
final Object[]
the second array, may be null
array2
)

Tests whether two arrays are the same length, treating null arrays as length 0.

public static boolean

Returns:

true if length of arrays matches, treating null as an empty array
isSameLength
(final short[]
the first array, may be null
array1
,
final short[]
the second array, may be null
array2
)

Tests whether two arrays are the same length, treating null arrays as length 0.

public static boolean

Returns:

true if type of arrays matches
isSameType
(final Object
the first array, must not be null
array1
,
final Object
the second array, must not be null
array2
)

Tests whether two arrays are the same type taking into account multidimensional arrays.

public static boolean

Returns:

whether the array is sorted according to natural ordering
isSorted
(final boolean[]
the array to check
array
)

Tests whether whether the provided array is sorted according to natural ordering (false before true).

public static boolean

Returns:

whether the array is sorted according to natural ordering
isSorted
(final byte[]
the array to check
array
)

Tests whether the provided array is sorted according to natural ordering.

public static boolean

Returns:

whether the array is sorted according to natural ordering
isSorted
(final char[]
the array to check
array
)

Tests whether the provided array is sorted according to natural ordering.

public static boolean

Returns:

whether the array is sorted according to natural ordering
isSorted
(final double[]
the array to check
array
)

Tests whether the provided array is sorted according to natural ordering.

public static boolean

Returns:

whether the array is sorted according to natural ordering
isSorted
(final float[]
the array to check
array
)

Tests whether the provided array is sorted according to natural ordering.

public static boolean

Returns:

whether the array is sorted according to natural ordering
isSorted
(final int[]
the array to check
array
)

Tests whether the provided array is sorted according to natural ordering.

public static boolean

Returns:

whether the array is sorted according to natural ordering
isSorted
(final long[]
the array to check
array
)

Tests whether the provided array is sorted according to natural ordering.

public static boolean

Returns:

whether the array is sorted according to natural ordering
isSorted
(final short[]
the array to check
array
)

Tests whether the provided array is sorted according to natural ordering.

public static <
the datatype of the array to check, it must implement Comparable
T extends Comparable<? super T>
>
boolean

Returns:

whether the array is sorted
isSorted
(final T[]
the array to check
array
)

Tests whether the provided array is sorted according to the class's compareTo method.

public static <
the datatype of the array
T
>
boolean

Returns:

whether the array is sorted
isSorted
(final T[]
the array to check
array
,
final Comparator<T>
the Comparator to compare over
comparator
)

Tests whether the provided array is sorted according to the provided Comparator.

public static int

Returns:

the last index of the value within the array, INDEX_NOT_FOUND (-1) if not found or null array input
lastIndexOf
(final boolean[]
the array to traverse backwards looking for the object, may be null
array
,
final boolean
the object to find
valueToFind
)

Finds the last index of the given value within the array.

public static int

Returns:

the last index of the value within the array, INDEX_NOT_FOUND (-1) if not found or null array input
lastIndexOf
(final boolean[]
the array to traverse for looking for the object, may be null
array
,
final boolean
the value to find
valueToFind
,
int
the start index to traverse backwards from
startIndex
)

Finds the last index of the given value in the array starting at the given index.

public static int

Returns:

the last index of the value within the array, INDEX_NOT_FOUND (-1) if not found or null array input
lastIndexOf
(final byte[]
the array to traverse backwards looking for the object, may be null
array
,
final byte
the object to find
valueToFind
)

Finds the last index of the given value within the array.

public static int

Returns:

the last index of the value within the array, INDEX_NOT_FOUND (-1) if not found or null array input
lastIndexOf
(final byte[]
the array to traverse for looking for the object, may be null
array
,
final byte
the value to find
valueToFind
,
int
the start index to traverse backwards from
startIndex
)

Finds the last index of the given value in the array starting at the given index.

public static int

Returns:

the last index of the value within the array, INDEX_NOT_FOUND (-1) if not found or null array input
lastIndexOf
(final char[]
the array to traverse backwards looking for the object, may be null
array
,
final char
the object to find
valueToFind
)

Finds the last index of the given value within the array.

public static int

Returns:

the last index of the value within the array, INDEX_NOT_FOUND (-1) if not found or null array input
lastIndexOf
(final char[]
the array to traverse for looking for the object, may be null
array
,
final char
the value to find
valueToFind
,
int
the start index to traverse backwards from
startIndex
)

Finds the last index of the given value in the array starting at the given index.

public static int

Returns:

the last index of the value within the array, INDEX_NOT_FOUND (-1) if not found or null array input
lastIndexOf
(final double[]
the array to traverse backwards looking for the object, may be null
array
,
final double
the object to find
valueToFind
)

Finds the last index of the given value within the array.

public static int

Returns:

the index of the value within the array, INDEX_NOT_FOUND (-1) if not found or null array input
lastIndexOf
(final double[]
the array to search for the object, may be null
array
,
final double
the value to find
valueToFind
,
final double
tolerance of the search
tolerance
)

Finds the last index of the given value within a given tolerance in the array.

public static int

Returns:

the last index of the value within the array, INDEX_NOT_FOUND (-1) if not found or null array input
lastIndexOf
(final double[]
the array to traverse for looking for the object, may be null
array
,
final double
the value to find
valueToFind
,
int
the start index to traverse backwards from
startIndex
)

Finds the last index of the given value in the array starting at the given index.

public static int

Returns:

the last index of the value within the array, INDEX_NOT_FOUND (-1) if not found or null array input
lastIndexOf
(final double[]
the array to traverse for looking for the object, may be null
array
,
final double
the value to find
valueToFind
,
int
the start index to traverse backwards from
startIndex
,
final double
search for value within plus/minus this amount
tolerance
)

Finds the last index of the given value in the array starting at the given index.

public static int

Returns:

the last index of the value within the array, INDEX_NOT_FOUND (-1) if not found or null array input
lastIndexOf
(final float[]
the array to traverse backwards looking for the object, may be null
array
,
final float
the object to find
valueToFind
)

Finds the last index of the given value within the array.

public static int

Returns:

the last index of the value within the array, INDEX_NOT_FOUND (-1) if not found or null array input
lastIndexOf
(final float[]
the array to traverse for looking for the object, may be null
array
,
final float
the value to find
valueToFind
,
int
the start index to traverse backwards from
startIndex
)

Finds the last index of the given value in the array starting at the given index.

public static int

Returns:

the last index of the value within the array, INDEX_NOT_FOUND (-1) if not found or null array input
lastIndexOf
(final int[]
the array to traverse backwards looking for the object, may be null
array
,
final int
the object to find
valueToFind
)

Finds the last index of the given value within the array.

public static int

Returns:

the last index of the value within the array, INDEX_NOT_FOUND (-1) if not found or null array input
lastIndexOf
(final int[]
the array to traverse for looking for the object, may be null
array
,
final int
the value to find
valueToFind
,
int
the start index to traverse backwards from
startIndex
)

Finds the last index of the given value in the array starting at the given index.

public static int

Returns:

the last index of the value within the array, INDEX_NOT_FOUND (-1) if not found or null array input
lastIndexOf
(final long[]
the array to traverse backwards looking for the object, may be null
array
,
final long
the object to find
valueToFind
)

Finds the last index of the given value within the array.

public static int

Returns:

the last index of the value within the array, INDEX_NOT_FOUND (-1) if not found or null array input
lastIndexOf
(final long[]
the array to traverse for looking for the object, may be null
array
,
final long
the value to find
valueToFind
,
int
the start index to traverse backwards from
startIndex
)

Finds the last index of the given value in the array starting at the given index.

public static int

Returns:

the last index of the object within the array, INDEX_NOT_FOUND (-1) if not found or null array input
lastIndexOf
(final Object[]
the array to traverse backwards looking for the object, may be null
array
,
final Object
the object to find, may be null
objectToFind
)

Finds the last index of the given object within the array.

public static int

Returns:

the last index of the object within the array, INDEX_NOT_FOUND (-1) if not found or null array input
lastIndexOf
(final Object[]
the array to traverse for looking for the object, may be null
array
,
final Object
the object to find, may be null
objectToFind
,
int
the start index to traverse backwards from
startIndex
)

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

public static int

Returns:

the last index of the value within the array, INDEX_NOT_FOUND (-1) if not found or null array input
lastIndexOf
(final short[]
the array to traverse backwards looking for the object, may be null
array
,
final short
the object to find
valueToFind
)

Finds the last index of the given value within the array.

public static int

Returns:

the last index of the value within the array, INDEX_NOT_FOUND (-1) if not found or null array input
lastIndexOf
(final short[]
the array to traverse for looking for the object, may be null
array
,
final short
the value to find
valueToFind
,
int
the start index to traverse backwards from
startIndex
)

Finds the last index of the given value in the array starting at the given index.

private static <
The input array type.
T
,
The output array type.
R
,
The type of exceptions thrown when the mapper function fails.
E extends Throwable
>
R[]

Returns:

a new array
map
(final T[]
The input array.
array
,
final Class<R>
the component type of the result array.
componentType
,
final FailableFunction<? super T, ? extends R, E>
a non-interfering, stateless function to apply to each element
mapper
)

Maps elements from an array into elements of a new array of a given type, while mapping old elements to new elements.

private static int
max0(final int other)

public static <
The array type.
T
>
T[]

Returns:

The new array.
newInstance
(final Class<T>
The array class.
componentType
,
final int
the array length
length
)

Delegates to Array#newInstance(Class, int) using generics.

public static <
The array type.
T
>
T[]

Returns:

the same array, or defaultArray if null or empty input.
nullTo
(final T[]
the array to check for null or empty
array
,
final T[]
A default array, usually empty.
defaultArray
)

Defensive programming technique to change a null reference to an empty one.

public static boolean[]

Returns:

the same array, public static empty array if null or empty input
nullToEmpty
(final boolean[]
the array to check for null or empty
array
)

Defensive programming technique to change a null reference to an empty one.

public static Boolean[]

Returns:

the same array, public static empty array if null or empty input
nullToEmpty
(final Boolean[]
the array to check for null or empty
array
)

Defensive programming technique to change a null reference to an empty one.

public static byte[]

Returns:

the same array, public static empty array if null or empty input
nullToEmpty
(final byte[]
the array to check for null or empty
array
)

Defensive programming technique to change a null reference to an empty one.

public static Byte[]

Returns:

the same array, public static empty array if null or empty input
nullToEmpty
(final Byte[]
the array to check for null or empty
array
)

Defensive programming technique to change a null reference to an empty one.

public static char[]

Returns:

the same array, public static empty array if null or empty input
nullToEmpty
(final char[]
the array to check for null or empty
array
)

Defensive programming technique to change a null reference to an empty one.

public static Character[]

Returns:

the same array, public static empty array if null or empty input
nullToEmpty
(final Character[]
the array to check for null or empty
array
)

Defensive programming technique to change a null reference to an empty one.

public static Class<?>[]

Returns:

the same array, public static empty array if null or empty input
nullToEmpty
(final Class<?>[]
the array to check for null or empty
array
)

Defensive programming technique to change a null reference to an empty one.

public static double[]

Returns:

the same array, public static empty array if null or empty input
nullToEmpty
(final double[]
the array to check for null or empty
array
)

Defensive programming technique to change a null reference to an empty one.

public static Double[]

Returns:

the same array, public static empty array if null or empty input
nullToEmpty
(final Double[]
the array to check for null or empty
array
)

Defensive programming technique to change a null reference to an empty one.

public static float[]

Returns:

the same array, public static empty array if null or empty input
nullToEmpty
(final float[]
the array to check for null or empty
array
)

Defensive programming technique to change a null reference to an empty one.

public static Float[]

Returns:

the same array, public static empty array if null or empty input
nullToEmpty
(final Float[]
the array to check for null or empty
array
)

Defensive programming technique to change a null reference to an empty one.

public static int[]

Returns:

the same array, public static empty array if null or empty input
nullToEmpty
(final int[]
the array to check for null or empty
array
)

Defensive programming technique to change a null reference to an empty one.

public static Integer[]

Returns:

the same array, public static empty array if null or empty input
nullToEmpty
(final Integer[]
the array to check for null or empty
array
)

Defensive programming technique to change a null reference to an empty one.

public static long[]

Returns:

the same array, public static empty array if null or empty input
nullToEmpty
(final long[]
the array to check for null or empty
array
)

Defensive programming technique to change a null reference to an empty one.

public static Long[]

Returns:

the same array, public static empty array if null or empty input
nullToEmpty
(final Long[]
the array to check for null or empty
array
)

Defensive programming technique to change a null reference to an empty one.

public static Object[]

Returns:

the same array, public static empty array if null or empty input
nullToEmpty
(final Object[]
the array to check for null or empty
array
)

Defensive programming technique to change a null reference to an empty one.

public static short[]

Returns:

the same array, public static empty array if null or empty input
nullToEmpty
(final short[]
the array to check for null or empty
array
)

Defensive programming technique to change a null reference to an empty one.

public static Short[]

Returns:

the same array, public static empty array if null or empty input
nullToEmpty
(final Short[]
the array to check for null or empty
array
)

Defensive programming technique to change a null reference to an empty one.

public static String[]

Returns:

the same array, public static empty array if null or empty input
nullToEmpty
(final String[]
the array to check for null or empty
array
)

Defensive programming technique to change a null reference to an empty one.

public static <
the class type
T
>
T[]

Returns:

the same array, public static empty array if null
nullToEmpty
(final T[]
the array to check for null or empty
array
,
final Class<T[]>
the class representation of the desired array
type
)

Defensive programming technique to change a null reference to an empty one.

private static ThreadLocalRandom

Returns:

the current ThreadLocalRandom.
random
()

Gets the ThreadLocalRandom for shuffle methods that don't take a Random argument.

public static boolean[]

Returns:

A new array containing the existing elements except the element at the specified position.
remove
(final boolean[]
the array to remove the element from, may not be null
array
,
final int
the position of the element to be removed
index
)

Removes the element at the specified position from the specified array.

public static byte[]

Returns:

A new array containing the existing elements except the element at the specified position.
remove
(final byte[]
the array to remove the element from, may not be null
array
,
final int
the position of the element to be removed
index
)

Removes the element at the specified position from the specified array.

public static char[]

Returns:

A new array containing the existing elements except the element at the specified position.
remove
(final char[]
the array to remove the element from, may not be null
array
,
final int
the position of the element to be removed
index
)

Removes the element at the specified position from the specified array.

public static double[]

Returns:

A new array containing the existing elements except the element at the specified position.
remove
(final double[]
the array to remove the element from, may not be null
array
,
final int
the position of the element to be removed
index
)

Removes the element at the specified position from the specified array.

public static float[]

Returns:

A new array containing the existing elements except the element at the specified position.
remove
(final float[]
the array to remove the element from, may not be null
array
,
final int
the position of the element to be removed
index
)

Removes the element at the specified position from the specified array.

public static int[]

Returns:

A new array containing the existing elements except the element at the specified position.
remove
(final int[]
the array to remove the element from, may not be null
array
,
final int
the position of the element to be removed
index
)

Removes the element at the specified position from the specified array.

public static long[]

Returns:

A new array containing the existing elements except the element at the specified position.
remove
(final long[]
the array to remove the element from, may not be null
array
,
final int
the position of the element to be removed
index
)

Removes the element at the specified position from the specified array.

private static Object

Returns:

A new array containing the existing elements except the element at the specified position.
remove
(final Object
the array to remove the element from, may not be null
array
,
final int
the position of the element to be removed
index
)

Removes the element at the specified position from the specified array.

public static short[]

Returns:

A new array containing the existing elements except the element at the specified position.
remove
(final short[]
the array to remove the element from, may not be null
array
,
final int
the position of the element to be removed
index
)

Removes the element at the specified position from the specified array.

public static <
the component type of the array
T
>
T[]

Returns:

A new array containing the existing elements except the element at the specified position.
remove
(final T[]
the array to remove the element from, may not be null
array
,
final int
the position of the element to be removed
index
)

Removes the element at the specified position from the specified array.

public static boolean[]

Returns:

A new array containing the existing elements except those at the specified positions.
removeAll
(final boolean[]
the array to remove the element from, may not be null
array
,
final int...
the positions of the elements to be removed
indices
)

Removes the elements at the specified positions from the specified array.

public static byte[]

Returns:

A new array containing the existing elements except those at the specified positions.
removeAll
(final byte[]
the array to remove the element from, may not be null
array
,
final int...
the positions of the elements to be removed
indices
)

Removes the elements at the specified positions from the specified array.

public static char[]

Returns:

A new array containing the existing elements except those at the specified positions.
removeAll
(final char[]
the array to remove the element from, may not be null
array
,
final int...
the positions of the elements to be removed
indices
)

Removes the elements at the specified positions from the specified array.

public static double[]

Returns:

A new array containing the existing elements except those at the specified positions.
removeAll
(final double[]
the array to remove the element from, may not be null
array
,
final int...
the positions of the elements to be removed
indices
)

Removes the elements at the specified positions from the specified array.

public static float[]

Returns:

A new array containing the existing elements except those at the specified positions.
removeAll
(final float[]
the array to remove the element from, may not be null
array
,
final int...
the positions of the elements to be removed
indices
)

Removes the elements at the specified positions from the specified array.

public static int[]

Returns:

A new array containing the existing elements except those at the specified positions.
removeAll
(final int[]
the array to remove the element from, may not be null
array
,
final int...
the positions of the elements to be removed
indices
)

Removes the elements at the specified positions from the specified array.

public static long[]

Returns:

A new array containing the existing elements except those at the specified positions.
removeAll
(final long[]
the array to remove the element from, may not be null
array
,
final int...
the positions of the elements to be removed
indices
)

Removes the elements at the specified positions from the specified array.

pack-priv static Object

Returns:

new array of same type minus elements specified by unique values of indices
removeAll
(final Object
source
array
,
final int...
to remove
indices
)

Removes multiple array elements specified by index.

public static short[]

Returns:

A new array containing the existing elements except those at the specified positions.
removeAll
(final short[]
the array to remove the element from, may not be null
array
,
final int...
the positions of the elements to be removed
indices
)

Removes the elements at the specified positions from the specified array.

public static <
the component type of the array
T
>
T[]

Returns:

A new array containing the existing elements except those at the specified positions.
removeAll
(final T[]
the array to remove the element from, may not be null
array
,
final int...
the positions of the elements to be removed
indices
)

Removes the elements at the specified positions from the specified array.

public static boolean[]

Returns:

A new array containing the existing elements except the occurrences of the specified element.
removeAllOccurences
(final boolean[]
the input array, will not be modified, and may be null.
array
,
final boolean
the element to remove.
element
)

Removes the occurrences of the specified element from the specified boolean array.

public static byte[]

Returns:

A new array containing the existing elements except the occurrences of the specified element.
removeAllOccurences
(final byte[]
the input array, will not be modified, and may be null.
array
,
final byte
the element to remove.
element
)

Removes the occurrences of the specified element from the specified byte array.

public static char[]

Returns:

A new array containing the existing elements except the occurrences of the specified element.
removeAllOccurences
(final char[]
the input array, will not be modified, and may be null.
array
,
final char
the element to remove.
element
)

Removes the occurrences of the specified element from the specified char array.

public static double[]

Returns:

A new array containing the existing elements except the occurrences of the specified element.
removeAllOccurences
(final double[]
the input array, will not be modified, and may be null.
array
,
final double
the element to remove.
element
)

Removes the occurrences of the specified element from the specified double array.

public static float[]

Returns:

A new array containing the existing elements except the occurrences of the specified element.
removeAllOccurences
(final float[]
the input array, will not be modified, and may be null.
array
,
final float
the element to remove.
element
)

Removes the occurrences of the specified element from the specified float array.

public static int[]

Returns:

A new array containing the existing elements except the occurrences of the specified element.
removeAllOccurences
(final int[]
the input array, will not be modified, and may be null.
array
,
final int
the element to remove.
element
)

Removes the occurrences of the specified element from the specified int array.

public static long[]

Returns:

A new array containing the existing elements except the occurrences of the specified element.
removeAllOccurences
(final long[]
the input array, will not be modified, and may be null.
array
,
final long
the element to remove.
element
)

Removes the occurrences of the specified element from the specified long array.

public static short[]

Returns:

A new array containing the existing elements except the occurrences of the specified element.
removeAllOccurences
(final short[]
the input array, will not be modified, and may be null.
array
,
final short
the element to remove.
element
)

Removes the occurrences of the specified element from the specified short array.

public static <
the type of object in the array, may be null.
T
>
T[]

Returns:

A new array containing the existing elements except the occurrences of the specified element.
removeAllOccurences
(final T[]
the input array, will not be modified, and may be null.
array
,
final T
the element to remove, may be null.
element
)

Removes the occurrences of the specified element from the specified array.

public static boolean[]

Returns:

A new array containing the existing elements except the occurrences of the specified element.
removeAllOccurrences
(final boolean[]
the input array, will not be modified, and may be null.
array
,
final boolean
the element to remove.
element
)

Removes the occurrences of the specified element from the specified boolean array.

public static byte[]

Returns:

A new array containing the existing elements except the occurrences of the specified element.
removeAllOccurrences
(final byte[]
the input array, will not be modified, and may be null.
array
,
final byte
the element to remove.
element
)

Removes the occurrences of the specified element from the specified byte array.

public static char[]

Returns:

A new array containing the existing elements except the occurrences of the specified element.
removeAllOccurrences
(final char[]
the input array, will not be modified, and may be null.
array
,
final char
the element to remove.
element
)

Removes the occurrences of the specified element from the specified char array.

public static double[]

Returns:

A new array containing the existing elements except the occurrences of the specified element.
removeAllOccurrences
(final double[]
the input array, will not be modified, and may be null.
array
,
final double
the element to remove.
element
)

Removes the occurrences of the specified element from the specified double array.

public static float[]

Returns:

A new array containing the existing elements except the occurrences of the specified element.
removeAllOccurrences
(final float[]
the input array, will not be modified, and may be null.
array
,
final float
the element to remove.
element
)

Removes the occurrences of the specified element from the specified float array.

public static int[]

Returns:

A new array containing the existing elements except the occurrences of the specified element.
removeAllOccurrences
(final int[]
the input array, will not be modified, and may be null.
array
,
final int
the element to remove.
element
)

Removes the occurrences of the specified element from the specified int array.

public static long[]

Returns:

A new array containing the existing elements except the occurrences of the specified element.
removeAllOccurrences
(final long[]
the input array, will not be modified, and may be null.
array
,
final long
the element to remove.
element
)

Removes the occurrences of the specified element from the specified long array.

public static short[]

Returns:

A new array containing the existing elements except the occurrences of the specified element.
removeAllOccurrences
(final short[]
the input array, will not be modified, and may be null.
array
,
final short
the element to remove.
element
)

Removes the occurrences of the specified element from the specified short array.

public static <
the type of object in the array, may be null.
T
>
T[]

Returns:

A new array containing the existing elements except the occurrences of the specified element.
removeAllOccurrences
(final T[]
the input array, will not be modified, and may be null.
array
,
final T
the element to remove, may be null.
element
)

Removes the occurrences of the specified element from the specified array.

pack-priv static Object

Returns:

new array of same type minus elements specified by the set bits in indices.
removeAt
(final Object
the input array, will not be modified, and may be null.
array
,
final BitSet
to remove.
indices
)

Removes multiple array elements specified by indices.

public static boolean[]

Returns:

A new array containing the existing elements except the first occurrence of the specified element.
removeElement
(final boolean[]
the input array, may be null.
array
,
final boolean
the element to be removed.
element
)

Removes the first occurrence of the specified element from the specified array.

public static byte[]

Returns:

A new array containing the existing elements except the first occurrence of the specified element.
removeElement
(final byte[]
the input array, may be null.
array
,
final byte
the element to be removed.
element
)

Removes the first occurrence of the specified element from the specified array.

public static char[]

Returns:

A new array containing the existing elements except the first occurrence of the specified element.
removeElement
(final char[]
the input array, may be null.
array
,
final char
the element to be removed.
element
)

Removes the first occurrence of the specified element from the specified array.

public static double[]

Returns:

A new array containing the existing elements except the first occurrence of the specified element.
removeElement
(final double[]
the input array, may be null.
array
,
final double
the element to be removed.
element
)

Removes the first occurrence of the specified element from the specified array.

public static float[]

Returns:

A new array containing the existing elements except the first occurrence of the specified element.
removeElement
(final float[]
the input array, may be null.
array
,
final float
the element to be removed.
element
)

Removes the first occurrence of the specified element from the specified array.

public static int[]

Returns:

A new array containing the existing elements except the first occurrence of the specified element.
removeElement
(final int[]
the input array, may be null.
array
,
final int
the element to be removed.
element
)

Removes the first occurrence of the specified element from the specified array.

public static long[]

Returns:

A new array containing the existing elements except the first occurrence of the specified element.
removeElement
(final long[]
the input array, may be null.
array
,
final long
the element to be removed.
element
)

Removes the first occurrence of the specified element from the specified array.

public static short[]

Returns:

A new array containing the existing elements except the first occurrence of the specified element.
removeElement
(final short[]
the input array, may be null.
array
,
final short
the element to be removed.
element
)

Removes the first occurrence of the specified element from the specified array.

public static <
the component type of the array
T
>
T[]

Returns:

A new array containing the existing elements except the first occurrence of the specified element.
removeElement
(final T[]
the input array, may be null.
array
,
final Object
the element to be removed, may be null.
element
)

Removes the first occurrence of the specified element from the specified array.

public static boolean[]

Returns:

A new array containing the existing elements except the earliest-encountered occurrences of the specified elements.
removeElements
(final boolean[]
the input array, will not be modified, and may be null.
array
,
final boolean...
the values to be removed.
values
)

Removes occurrences of specified elements, in specified quantities, from the specified array.

public static byte[]

Returns:

A new array containing the existing elements except the earliest-encountered occurrences of the specified elements.
removeElements
(final byte[]
the input array, will not be modified, and may be null.
array
,
final byte...
the values to be removed.
values
)

Removes occurrences of specified elements, in specified quantities, from the specified array.

public static char[]

Returns:

A new array containing the existing elements except the earliest-encountered occurrences of the specified elements.
removeElements
(final char[]
the input array, will not be modified, and may be null.
array
,
final char...
the values to be removed.
values
)

Removes occurrences of specified elements, in specified quantities, from the specified array.

public static double[]

Returns:

A new array containing the existing elements except the earliest-encountered occurrences of the specified elements.
removeElements
(final double[]
the input array, will not be modified, and may be null.
array
,
final double...
the values to be removed.
values
)

Removes occurrences of specified elements, in specified quantities, from the specified array.

public static float[]

Returns:

A new array containing the existing elements except the earliest-encountered occurrences of the specified elements.
removeElements
(final float[]
the input array, will not be modified, and may be null.
array
,
final float...
the values to be removed.
values
)

Removes occurrences of specified elements, in specified quantities, from the specified array.

public static int[]

Returns:

A new array containing the existing elements except the earliest-encountered occurrences of the specified elements.
removeElements
(final int[]
the input array, will not be modified, and may be null.
array
,
final int...
the values to be removed.
values
)

Removes occurrences of specified elements, in specified quantities, from the specified array.

public static long[]

Returns:

A new array containing the existing elements except the earliest-encountered occurrences of the specified elements.
removeElements
(final long[]
the input array, will not be modified, and may be null.
array
,
final long...
the values to be removed.
values
)

Removes occurrences of specified elements, in specified quantities, from the specified array.

public static short[]

Returns:

A new array containing the existing elements except the earliest-encountered occurrences of the specified elements.
removeElements
(final short[]
the input array, will not be modified, and may be null.
array
,
final short...
the values to be removed.
values
)

Removes occurrences of specified elements, in specified quantities, from the specified array.

public static <
the component type of the array
T
>
T[]

Returns:

A new array containing the existing elements except the earliest-encountered occurrences of the specified elements.
removeElements
(final T[]
the input array, will not be modified, and may be null.
array
,
final T...
the values to be removed.
values
)

Removes occurrences of specified elements, in specified quantities, from the specified array.

public static void
reverse(final boolean[]
the array to reverse, may be null.
array
)

Reverses the order of the given array.

public static void
reverse(final boolean[]
the array to reverse, may be null.
array
,
final int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in no change.
startIndexInclusive
,
final int
elements up to endIndex-1 are reversed in the array. Undervalue (< start index) results in no change. Overvalue (>array.length) is demoted to array length.
endIndexExclusive
)

Reverses the order of the given array in the given range.

public static void
reverse(final byte[]
the array to reverse, may be null
array
)

Reverses the order of the given array.

public static void
reverse(final byte[]
the array to reverse, may be null
array
,
final int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in no change.
startIndexInclusive
,
final int
elements up to endIndex-1 are reversed in the array. Undervalue (< start index) results in no change. Overvalue (>array.length) is demoted to array length.
endIndexExclusive
)

Reverses the order of the given array in the given range.

public static void
reverse(final char[]
the array to reverse, may be null
array
)

Reverses the order of the given array.

public static void
reverse(final char[]
the array to reverse, may be null
array
,
final int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in no change.
startIndexInclusive
,
final int
elements up to endIndex-1 are reversed in the array. Undervalue (< start index) results in no change. Overvalue (>array.length) is demoted to array length.
endIndexExclusive
)

Reverses the order of the given array in the given range.

public static void
reverse(final double[]
the array to reverse, may be null
array
)

Reverses the order of the given array.

public static void
reverse(final double[]
the array to reverse, may be null
array
,
final int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in no change.
startIndexInclusive
,
final int
elements up to endIndex-1 are reversed in the array. Undervalue (< start index) results in no change. Overvalue (>array.length) is demoted to array length.
endIndexExclusive
)

Reverses the order of the given array in the given range.

public static void
reverse(final float[]
the array to reverse, may be null.
array
)

Reverses the order of the given array.

public static void
reverse(final float[]
the array to reverse, may be null.
array
,
final int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in no change.
startIndexInclusive
,
final int
elements up to endIndex-1 are reversed in the array. Undervalue (< start index) results in no change. Overvalue (>array.length) is demoted to array length.
endIndexExclusive
)

Reverses the order of the given array in the given range.

public static void
reverse(final int[]
the array to reverse, may be null.
array
)

Reverses the order of the given array.

public static void
reverse(final int[]
the array to reverse, may be null.
array
,
final int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in no change.
startIndexInclusive
,
final int
elements up to endIndex-1 are reversed in the array. Undervalue (< start index) results in no change. Overvalue (>array.length) is demoted to array length.
endIndexExclusive
)

Reverses the order of the given array in the given range.

public static void
reverse(final long[]
the array to reverse, may be null.
array
)

Reverses the order of the given array.

public static void
reverse(final long[]
the array to reverse, may be null.
array
,
final int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in no change.
startIndexInclusive
,
final int
elements up to endIndex-1 are reversed in the array. Undervalue (< start index) results in no change. Overvalue (>array.length) is demoted to array length.
endIndexExclusive
)

Reverses the order of the given array in the given range.

public static void
reverse(final Object[]
the array to reverse, may be null.
array
)

Reverses the order of the given array.

public static void
reverse(final Object[]
the array to reverse, may be null.
array
,
final int
the starting index. Under value (<0) is promoted to 0, over value (>array.length) results in no change.
startIndexInclusive
,
final int
elements up to endIndex-1 are reversed in the array. Under value (< start index) results in no change. Over value (>array.length) is demoted to array length.
endIndexExclusive
)

Reverses the order of the given array in the given range.

public static void
reverse(final short[]
the array to reverse, may be null.
array
)

Reverses the order of the given array.

public static void
reverse(final short[]
the array to reverse, may be null.
array
,
final int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in no change.
startIndexInclusive
,
final int
elements up to endIndex-1 are reversed in the array. Undervalue (< start index) results in no change. Overvalue (>array.length) is demoted to array length.
endIndexExclusive
)

Reverses the order of the given array in the given range.

public static <
type of elements of the array, may be null.
T
>
T[]

Returns:

the input array
setAll
(final T[]
array to be initialized, may be null.
array
,
final IntFunction<? extends T>
a function accepting an index and producing the desired value for that position.
generator
)

Sets all elements of the specified array, using the provided generator supplier to compute each element.

public static <
type of elements of the array, may be null.
T
>
T[]

Returns:

the input array
setAll
(final T[]
array to be initialized, may be null.
array
,
final Supplier<? extends T>
a function accepting an index and producing the desired value for that position.
generator
)

Sets all elements of the specified array, using the provided generator supplier to compute each element.

public static void
shift(final boolean[]
the array to shift, may be null.
array
,
final int
The number of positions to rotate the elements. If the offset is larger than the number of elements to rotate, than the effective offset is modulo the number of elements to rotate.
offset
)

Shifts the order of the given boolean array.

public static void
shift(final boolean[]
the array to shift, may be null.
array
,
int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in no change.
startIndexInclusive
,
int
elements up to endIndex-1 are shifted in the array. Undervalue (< start index) results in no change. Overvalue (>array.length) is demoted to array length.
endIndexExclusive
,
int
The number of positions to rotate the elements. If the offset is larger than the number of elements to rotate, than the effective offset is modulo the number of elements to rotate.
offset
)

Shifts the order of a series of elements in the given boolean array.

public static void
shift(final byte[]
the array to shift, may be null.
array
,
final int
The number of positions to rotate the elements. If the offset is larger than the number of elements to rotate, than the effective offset is modulo the number of elements to rotate.
offset
)

Shifts the order of the given byte array.

public static void
shift(final byte[]
the array to shift, may be null.
array
,
int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in no change.
startIndexInclusive
,
int
elements up to endIndex-1 are shifted in the array. Undervalue (< start index) results in no change. Overvalue (>array.length) is demoted to array length.
endIndexExclusive
,
int
The number of positions to rotate the elements. If the offset is larger than the number of elements to rotate, than the effective offset is modulo the number of elements to rotate.
offset
)

Shifts the order of a series of elements in the given byte array.

public static void
shift(final char[]
the array to shift, may be null.
array
,
final int
The number of positions to rotate the elements. If the offset is larger than the number of elements to rotate, than the effective offset is modulo the number of elements to rotate.
offset
)

Shifts the order of the given char array.

public static void
shift(final char[]
the array to shift, may be null.
array
,
int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in no change.
startIndexInclusive
,
int
elements up to endIndex-1 are shifted in the array. Undervalue (< start index) results in no change. Overvalue (>array.length) is demoted to array length.
endIndexExclusive
,
int
The number of positions to rotate the elements. If the offset is larger than the number of elements to rotate, than the effective offset is modulo the number of elements to rotate.
offset
)

Shifts the order of a series of elements in the given char array.

public static void
shift(final double[]
the array to shift, may be null.
array
,
final int
The number of positions to rotate the elements. If the offset is larger than the number of elements to rotate, than the effective offset is modulo the number of elements to rotate.
offset
)

Shifts the order of the given double array.

public static void
shift(final double[]
the array to shift, may be null.
array
,
int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in no change.
startIndexInclusive
,
int
elements up to endIndex-1 are shifted in the array. Undervalue (< start index) results in no change. Overvalue (>array.length) is demoted to array length.
endIndexExclusive
,
int
The number of positions to rotate the elements. If the offset is larger than the number of elements to rotate, than the effective offset is modulo the number of elements to rotate.
offset
)

Shifts the order of a series of elements in the given double array.

public static void
shift(final float[]
the array to shift, may be null.
array
,
final int
The number of positions to rotate the elements. If the offset is larger than the number of elements to rotate, than the effective offset is modulo the number of elements to rotate.
offset
)

Shifts the order of the given float array.

public static void
shift(final float[]
the array to shift, may be null.
array
,
int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in no change.
startIndexInclusive
,
int
elements up to endIndex-1 are shifted in the array. Undervalue (< start index) results in no change. Overvalue (>array.length) is demoted to array length.
endIndexExclusive
,
int
The number of positions to rotate the elements. If the offset is larger than the number of elements to rotate, than the effective offset is modulo the number of elements to rotate.
offset
)

Shifts the order of a series of elements in the given float array.

public static void
shift(final int[]
the array to shift, may be null.
array
,
final int
The number of positions to rotate the elements. If the offset is larger than the number of elements to rotate, than the effective offset is modulo the number of elements to rotate.
offset
)

Shifts the order of the given int array.

public static void
shift(final int[]
the array to shift, may be null.
array
,
int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in no change.
startIndexInclusive
,
int
elements up to endIndex-1 are shifted in the array. Undervalue (< start index) results in no change. Overvalue (>array.length) is demoted to array length.
endIndexExclusive
,
int
The number of positions to rotate the elements. If the offset is larger than the number of elements to rotate, than the effective offset is modulo the number of elements to rotate.
offset
)

Shifts the order of a series of elements in the given int array.

public static void
shift(final long[]
the array to shift, may be null.
array
,
final int
The number of positions to rotate the elements. If the offset is larger than the number of elements to rotate, than the effective offset is modulo the number of elements to rotate.
offset
)

Shifts the order of the given long array.

public static void
shift(final long[]
the array to shift, may be null.
array
,
int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in no change.
startIndexInclusive
,
int
elements up to endIndex-1 are shifted in the array. Undervalue (< start index) results in no change. Overvalue (>array.length) is demoted to array length.
endIndexExclusive
,
int
The number of positions to rotate the elements. If the offset is larger than the number of elements to rotate, than the effective offset is modulo the number of elements to rotate.
offset
)

Shifts the order of a series of elements in the given long array.

public static void
shift(final Object[]
the array to shift, may be null.
array
,
final int
The number of positions to rotate the elements. If the offset is larger than the number of elements to rotate, than the effective offset is modulo the number of elements to rotate.
offset
)

Shifts the order of the given array.

public static void
shift(final Object[]
the array to shift, may be null.
array
,
int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in no change.
startIndexInclusive
,
int
elements up to endIndex-1 are shifted in the array. Undervalue (< start index) results in no change. Overvalue (>array.length) is demoted to array length.
endIndexExclusive
,
int
The number of positions to rotate the elements. If the offset is larger than the number of elements to rotate, than the effective offset is modulo the number of elements to rotate.
offset
)

Shifts the order of a series of elements in the given array.

public static void
shift(final short[]
the array to shift, may be null.
array
,
final int
The number of positions to rotate the elements. If the offset is larger than the number of elements to rotate, than the effective offset is modulo the number of elements to rotate.
offset
)

Shifts the order of the given short array.

public static void
shift(final short[]
the array to shift, may be null.
array
,
int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in no change.
startIndexInclusive
,
int
elements up to endIndex-1 are shifted in the array. Undervalue (< start index) results in no change. Overvalue (>array.length) is demoted to array length.
endIndexExclusive
,
int
The number of positions to rotate the elements. If the offset is larger than the number of elements to rotate, than the effective offset is modulo the number of elements to rotate.
offset
)

Shifts the order of a series of elements in the given short array.

public static void
shuffle(final boolean[]
the array to shuffle.
array
)

Shuffles randomly the elements of the specified array using the Fisher-Yates shuffle algorithm.

public static void
shuffle(final boolean[]
the array to shuffle
array
,
final Random
the source of randomness used to permute the elements
random
)

Shuffles randomly the elements of the specified array using the Fisher-Yates shuffle algorithm.

public static void
shuffle(final byte[]
the array to shuffle.
array
)

Shuffles randomly the elements of the specified array using the Fisher-Yates shuffle algorithm.

public static void
shuffle(final byte[]
the array to shuffle
array
,
final Random
the source of randomness used to permute the elements
random
)

Shuffles randomly the elements of the specified array using the Fisher-Yates shuffle algorithm.

public static void
shuffle(final char[]
the array to shuffle.
array
)

Shuffles randomly the elements of the specified array using the Fisher-Yates shuffle algorithm.

public static void
shuffle(final char[]
the array to shuffle
array
,
final Random
the source of randomness used to permute the elements
random
)

Shuffles randomly the elements of the specified array using the Fisher-Yates shuffle algorithm.

public static void
shuffle(final double[]
the array to shuffle.
array
)

Shuffles randomly the elements of the specified array using the Fisher-Yates shuffle algorithm.

public static void
shuffle(final double[]
the array to shuffle
array
,
final Random
the source of randomness used to permute the elements
random
)

Shuffles randomly the elements of the specified array using the Fisher-Yates shuffle algorithm.

public static void
shuffle(final float[]
the array to shuffle.
array
)

Shuffles randomly the elements of the specified array using the Fisher-Yates shuffle algorithm.

public static void
shuffle(final float[]
the array to shuffle
array
,
final Random
the source of randomness used to permute the elements
random
)

Shuffles randomly the elements of the specified array using the Fisher-Yates shuffle algorithm.

public static void
shuffle(final int[]
the array to shuffle.
array
)

Shuffles randomly the elements of the specified array using the Fisher-Yates shuffle algorithm.

public static void
shuffle(final int[]
the array to shuffle
array
,
final Random
the source of randomness used to permute the elements
random
)

Shuffles randomly the elements of the specified array using the Fisher-Yates shuffle algorithm.

public static void
shuffle(final long[]
the array to shuffle.
array
)

Shuffles randomly the elements of the specified array using the Fisher-Yates shuffle algorithm.

public static void
shuffle(final long[]
the array to shuffle
array
,
final Random
the source of randomness used to permute the elements
random
)

Shuffles randomly the elements of the specified array using the Fisher-Yates shuffle algorithm.

public static void
shuffle(final Object[]
the array to shuffle.
array
)

Shuffles randomly the elements of the specified array using the Fisher-Yates shuffle algorithm.

public static void
shuffle(final Object[]
the array to shuffle
array
,
final Random
the source of randomness used to permute the elements
random
)

Shuffles randomly the elements of the specified array using the Fisher-Yates shuffle algorithm.

public static void
shuffle(final short[]
the array to shuffle.
array
)

Shuffles randomly the elements of the specified array using the Fisher-Yates shuffle algorithm.

public static void
shuffle(final short[]
the array to shuffle
array
,
final Random
the source of randomness used to permute the elements
random
)

Shuffles randomly the elements of the specified array using the Fisher-Yates shuffle algorithm.

public static boolean

Returns:

whether a match was found.
startsWith
(final byte[]
The data to search, maybe larger than the expected data.
data
,
final byte[]
The expected data to find.
expected
)

Tests whether the given data array starts with an expected array, for example, signature bytes.

public static boolean[]

Returns:

a new array containing the elements between the start and end indices.
subarray
(final boolean[]
the array
array
,
int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in an empty array.
startIndexInclusive
,
int
elements up to endIndex-1 are present in the returned subarray. Undervalue (< startIndex) produces empty array, overvalue (>array.length) is demoted to array length.
endIndexExclusive
)

Produces a new boolean array containing the elements between the start and end indices.

public static byte[]

Returns:

a new array containing the elements between the start and end indices.
subarray
(final byte[]
the array
array
,
int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in an empty array.
startIndexInclusive
,
int
elements up to endIndex-1 are present in the returned subarray. Undervalue (< startIndex) produces empty array, overvalue (>array.length) is demoted to array length.
endIndexExclusive
)

Produces a new byte array containing the elements between the start and end indices.

public static char[]

Returns:

a new array containing the elements between the start and end indices.
subarray
(final char[]
the array
array
,
int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in an empty array.
startIndexInclusive
,
int
elements up to endIndex-1 are present in the returned subarray. Undervalue (< startIndex) produces empty array, overvalue (>array.length) is demoted to array length.
endIndexExclusive
)

Produces a new char array containing the elements between the start and end indices.

public static double[]

Returns:

a new array containing the elements between the start and end indices.
subarray
(final double[]
the array
array
,
int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in an empty array.
startIndexInclusive
,
int
elements up to endIndex-1 are present in the returned subarray. Undervalue (< startIndex) produces empty array, overvalue (>array.length) is demoted to array length.
endIndexExclusive
)

Produces a new double array containing the elements between the start and end indices.

public static float[]

Returns:

a new array containing the elements between the start and end indices.
subarray
(final float[]
the array
array
,
int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in an empty array.
startIndexInclusive
,
int
elements up to endIndex-1 are present in the returned subarray. Undervalue (< startIndex) produces empty array, overvalue (>array.length) is demoted to array length.
endIndexExclusive
)

Produces a new float array containing the elements between the start and end indices.

public static int[]

Returns:

a new array containing the elements between the start and end indices.
subarray
(final int[]
the array
array
,
int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in an empty array.
startIndexInclusive
,
int
elements up to endIndex-1 are present in the returned subarray. Undervalue (< startIndex) produces empty array, overvalue (>array.length) is demoted to array length.
endIndexExclusive
)

Produces a new int array containing the elements between the start and end indices.

public static long[]

Returns:

a new array containing the elements between the start and end indices.
subarray
(final long[]
the array
array
,
int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in an empty array.
startIndexInclusive
,
int
elements up to endIndex-1 are present in the returned subarray. Undervalue (< startIndex) produces empty array, overvalue (>array.length) is demoted to array length.
endIndexExclusive
)

Produces a new long array containing the elements between the start and end indices.

public static short[]

Returns:

a new array containing the elements between the start and end indices.
subarray
(final short[]
the array
array
,
int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in an empty array.
startIndexInclusive
,
int
elements up to endIndex-1 are present in the returned subarray. Undervalue (< startIndex) produces empty array, overvalue (>array.length) is demoted to array length.
endIndexExclusive
)

Produces a new short array containing the elements between the start and end indices.

public static <
the component type of the array
T
>
T[]

Returns:

a new array containing the elements between the start and end indices.
subarray
(final T[]
the array
array
,
int
the starting index. Undervalue (<0) is promoted to 0, overvalue (>array.length) results in an empty array.
startIndexInclusive
,
int
elements up to endIndex-1 are present in the returned subarray. Undervalue (< startIndex) produces empty array, overvalue (>array.length) is demoted to array length.
endIndexExclusive
)

Produces a new array containing the elements between the start and end indices.

public static void
swap(final boolean[]
the array to swap, may be null.
array
,
final int
the index of the first element to swap
offset1
,
final int
the index of the second element to swap
offset2
)

Swaps two elements in the given boolean array.

public static void
swap(final boolean[]
the array to swap, may be null.
array
,
int
the index of the first element in the series to swap
offset1
,
int
the index of the second element in the series to swap
offset2
,
int
the number of elements to swap starting with the given indices
len
)

Swaps a series of elements in the given boolean array.

public static void
swap(final byte[]
the array to swap, may be null.
array
,
final int
the index of the first element to swap
offset1
,
final int
the index of the second element to swap
offset2
)

Swaps two elements in the given byte array.

public static void
swap(final byte[]
the array to swap, may be null.
array
,
int
the index of the first element in the series to swap
offset1
,
int
the index of the second element in the series to swap
offset2
,
int
the number of elements to swap starting with the given indices
len
)

Swaps a series of elements in the given byte array.

public static void
swap(final char[]
the array to swap, may be null.
array
,
final int
the index of the first element to swap
offset1
,
final int
the index of the second element to swap
offset2
)

Swaps two elements in the given char array.

public static void
swap(final char[]
the array to swap, may be null.
array
,
int
the index of the first element in the series to swap
offset1
,
int
the index of the second element in the series to swap
offset2
,
int
the number of elements to swap starting with the given indices
len
)

Swaps a series of elements in the given char array.

public static void
swap(final double[]
the array to swap, may be null.
array
,
final int
the index of the first element to swap
offset1
,
final int
the index of the second element to swap
offset2
)

Swaps two elements in the given double array.

public static void
swap(final double[]
the array to swap, may be null.
array
,
int
the index of the first element in the series to swap
offset1
,
int
the index of the second element in the series to swap
offset2
,
int
the number of elements to swap starting with the given indices
len
)

Swaps a series of elements in the given double array.

public static void
swap(final float[]
the array to swap, may be null.
array
,
final int
the index of the first element to swap
offset1
,
final int
the index of the second element to swap
offset2
)

Swaps two elements in the given float array.

public static void
swap(final float[]
the array to swap, may be null.
array
,
int
the index of the first element in the series to swap
offset1
,
int
the index of the second element in the series to swap
offset2
,
int
the number of elements to swap starting with the given indices
len
)

Swaps a series of elements in the given float array.

public static void
swap(final int[]
the array to swap, may be null
array
,
final int
the index of the first element to swap
offset1
,
final int
the index of the second element to swap
offset2
)

Swaps two elements in the given int array.

public static void
swap(final int[]
the array to swap, may be null
array
,
int
the index of the first element in the series to swap
offset1
,
int
the index of the second element in the series to swap
offset2
,
int
the number of elements to swap starting with the given indices
len
)

Swaps a series of elements in the given int array.

public static void
swap(final long[]
the array to swap, may be null
array
,
final int
the index of the first element to swap
offset1
,
final int
the index of the second element to swap
offset2
)

Swaps two elements in the given long array.

public static void
swap(final long[]
the array to swap, may be null
array
,
int
the index of the first element in the series to swap
offset1
,
int
the index of the second element in the series to swap
offset2
,
int
the number of elements to swap starting with the given indices
len
)

Swaps a series of elements in the given long array.

public static void
swap(final Object[]
the array to swap, may be null
array
,
final int
the index of the first element to swap
offset1
,
final int
the index of the second element to swap
offset2
)

Swaps two elements in the given array.

public static void
swap(final Object[]
the array to swap, may be null
array
,
int
the index of the first element in the series to swap
offset1
,
int
the index of the second element in the series to swap
offset2
,
int
the number of elements to swap starting with the given indices
len
)

Swaps a series of elements in the given array.

public static void
swap(final short[]
the array to swap, may be null
array
,
final int
the index of the first element to swap
offset1
,
final int
the index of the second element to swap
offset2
)

Swaps two elements in the given short array.

public static void
swap(final short[]
the array to swap, may be null
array
,
int
the index of the first element in the series to swap
offset1
,
int
the index of the second element in the series to swap
offset2
,
int
the number of elements to swap starting with the given indices
len
)

Swaps a series of elements in the given short array.

public static <
the array's element type
T
>
T[]

Returns:

the array, not null unless a null array is passed in
toArray
(final T...
the varargs array items, null allowed
items
)

Create a type-safe generic array.

public static Map<Object, Object>

Returns:

a Map that was created from the array
toMap
(final Object[]
an array whose elements are either a java.util.Map.Entry or an Array containing at least two elements, may be null
array
)

Converts the given array into a java.util.Map.

public static Boolean[]

Returns:

a Boolean array, null if null array input
toObject
(final boolean[]
a boolean array
array
)

Converts an array of primitive booleans to objects.

public static Byte[]

Returns:

a Byte array, null if null array input
toObject
(final byte[]
a byte array
array
)

Converts an array of primitive bytes to objects.

public static Character[]

Returns:

a Character array, null if null array input
toObject
(final char[]
a char array
array
)

Converts an array of primitive chars to objects.

public static Double[]

Returns:

a Double array, null if null array input
toObject
(final double[]
a double array
array
)

Converts an array of primitive doubles to objects.

public static Float[]

Returns:

a Float array, null if null array input
toObject
(final float[]
a float array
array
)

Converts an array of primitive floats to objects.

public static Integer[]

Returns:

an Integer array, null if null array input
toObject
(final int[]
an int array
array
)

Converts an array of primitive ints to objects.

public static Long[]

Returns:

a Long array, null if null array input
toObject
(final long[]
a long array
array
)

Converts an array of primitive longs to objects.

public static Short[]

Returns:

a Short array, null if null array input
toObject
(final short[]
a short array
array
)

Converts an array of primitive shorts to objects.

public static boolean[]

Returns:

a boolean array, null if null array input
toPrimitive
(final Boolean[]
a Boolean array, may be null
array
)

Converts an array of object Booleans to primitives.

public static boolean[]

Returns:

a boolean array, null if null array input
toPrimitive
(final Boolean[]
a Boolean array, may be null
array
,
final boolean
the value to insert if null found
valueForNull
)

Converts an array of object Booleans to primitives handling null.

public static byte[]

Returns:

a byte array, null if null array input
toPrimitive
(final Byte[]
a Byte array, may be null
array
)

Converts an array of object Bytes to primitives.

public static byte[]

Returns:

a byte array, null if null array input
toPrimitive
(final Byte[]
a Byte array, may be null
array
,
final byte
the value to insert if null found
valueForNull
)

Converts an array of object Bytes to primitives handling null.

public static char[]

Returns:

a char array, null if null array input
toPrimitive
(final Character[]
a Character array, may be null
array
)

Converts an array of object Characters to primitives.

public static char[]

Returns:

a char array, null if null array input
toPrimitive
(final Character[]
a Character array, may be null
array
,
final char
the value to insert if null found
valueForNull
)

Converts an array of object Character to primitives handling null.

public static double[]

Returns:

a double array, null if null array input
toPrimitive
(final Double[]
a Double array, may be null
array
)

Converts an array of object Doubles to primitives.

public static double[]

Returns:

a double array, null if null array input
toPrimitive
(final Double[]
a Double array, may be null
array
,
final double
the value to insert if null found
valueForNull
)

Converts an array of object Doubles to primitives handling null.

public static float[]

Returns:

a float array, null if null array input
toPrimitive
(final Float[]
a Float array, may be null
array
)

Converts an array of object Floats to primitives.

public static float[]

Returns:

a float array, null if null array input
toPrimitive
(final Float[]
a Float array, may be null
array
,
final float
the value to insert if null found
valueForNull
)

Converts an array of object Floats to primitives handling null.

public static int[]

Returns:

an int array, null if null array input
toPrimitive
(final Integer[]
a Integer array, may be null
array
)

Converts an array of object Integers to primitives.

public static int[]

Returns:

an int array, null if null array input
toPrimitive
(final Integer[]
a Integer array, may be null
array
,
final int
the value to insert if null found
valueForNull
)

Converts an array of object Integer to primitives handling null.

public static long[]

Returns:

a long array, null if null array input
toPrimitive
(final Long[]
a Long array, may be null
array
)

Converts an array of object Longs to primitives.

public static long[]

Returns:

a long array, null if null array input
toPrimitive
(final Long[]
a Long array, may be null
array
,
final long
the value to insert if null found
valueForNull
)

Converts an array of object Long to primitives handling null.

public static Object

Returns:

an array of the corresponding primitive type, or the original array
toPrimitive
(final Object
an array of wrapper object
array
)

Create an array of primitive type from an array of wrapper types.

public static short[]

Returns:

a byte array, null if null array input
toPrimitive
(final Short[]
a Short array, may be null
array
)

Converts an array of object Shorts to primitives.

public static short[]

Returns:

a byte array, null if null array input
toPrimitive
(final Short[]
a Short array, may be null
array
,
final short
the value to insert if null found
valueForNull
)

Converts an array of object Short to primitives handling null.

public static String

Returns:

a String representation of the array, '{}' if null array input
toString
(final Object
the array to get a toString for, may be null
array
)

Outputs an array as a String, treating null as an empty array.

public static String

Returns:

a String representation of the array
toString
(final Object
the array to get a toString for, may be null
array
,
final String
the String to return if the array is null
stringIfNull
)

Outputs an array as a String handling nulls.

public static String[]

Returns:

String[] of the same size as the source with its element's string representation, null if null array input
toStringArray
(final Object[]
the Object[] to be processed, may be null.
array
)

Returns an array containing the string representation of each element in the argument array.

public static String[]

Returns:

a String array, null if null array input
toStringArray
(final Object[]
the Object[] to be processed, may be null.
array
,
final String
the value to insert if null is found
valueForNullElements
)

Returns an array containing the string representation of each element in the argument array handling null elements.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait