Android Utililty Methods Array Last Index Of

List of utility methods to do Array Last Index Of

Description

The list of methods to do Array Last Index Of are organized into topic(s).

Method

intlastIndexOf(Object[] array, Object objectToFind)

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

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

return lastIndexOf(array, objectToFind, Integer.MAX_VALUE);
intlastIndexOf(Object[] array, Object objectToFind, int startIndex)

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

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

A negative startIndex will return #INDEX_NOT_FOUND (-1).

if (array == null) {
    return INDEX_NOT_FOUND;
if (startIndex < 0) {
    return INDEX_NOT_FOUND;
} else if (startIndex >= array.length) {
    startIndex = array.length - 1;
if (objectToFind == null) {
    for (int i = startIndex; i >= 0; i--) {
        if (array[i] == null) {
            return i;
} else if (array.getClass().getComponentType()
        .isInstance(objectToFind)) {
    for (int i = startIndex; i >= 0; i--) {
        if (objectToFind.equals(array[i])) {
            return i;
return INDEX_NOT_FOUND;
intlastIndexOf(boolean[] array, boolean valueToFind)

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

This method returns #INDEX_NOT_FOUND (-1) if null array input.

return lastIndexOf(array, valueToFind, Integer.MAX_VALUE);
intlastIndexOf(boolean[] array, boolean valueToFind, int startIndex)

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

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

A negative startIndex will return #INDEX_NOT_FOUND (-1).

if (ArrayUtils.isEmpty(array)) {
    return INDEX_NOT_FOUND;
if (startIndex < 0) {
    return INDEX_NOT_FOUND;
} else if (startIndex >= array.length) {
    startIndex = array.length - 1;
for (int i = startIndex; i >= 0; i--) {
    if (valueToFind == array[i]) {
        return i;
return INDEX_NOT_FOUND;
intlastIndexOf(byte[] array, byte valueToFind)

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

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

return lastIndexOf(array, valueToFind, Integer.MAX_VALUE);
intlastIndexOf(byte[] array, byte valueToFind, int startIndex)

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

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

A negative startIndex will return #INDEX_NOT_FOUND (-1).

if (array == null) {
    return INDEX_NOT_FOUND;
if (startIndex < 0) {
    return INDEX_NOT_FOUND;
} else if (startIndex >= array.length) {
    startIndex = array.length - 1;
for (int i = startIndex; i >= 0; i--) {
    if (valueToFind == array[i]) {
        return i;
return INDEX_NOT_FOUND;
intlastIndexOf(char[] array, char valueToFind)

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

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

return lastIndexOf(array, valueToFind, Integer.MAX_VALUE);
intlastIndexOf(char[] array, char valueToFind, int startIndex)

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

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

A negative startIndex will return #INDEX_NOT_FOUND (-1).

if (array == null) {
    return INDEX_NOT_FOUND;
if (startIndex < 0) {
    return INDEX_NOT_FOUND;
} else if (startIndex >= array.length) {
    startIndex = array.length - 1;
for (int i = startIndex; i >= 0; i--) {
    if (valueToFind == array[i]) {
        return i;
return INDEX_NOT_FOUND;
intlastIndexOf(double[] array, double valueToFind)

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

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

return lastIndexOf(array, valueToFind, Integer.MAX_VALUE);
intlastIndexOf(double[] array, double valueToFind, double tolerance)

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

return lastIndexOf(array, valueToFind, Integer.MAX_VALUE, tolerance);