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(double[] array, double 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(double[] array, double valueToFind, int startIndex, double tolerance)

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

if (ArrayUtils.isEmpty(array)) {
    return INDEX_NOT_FOUND;
if (startIndex < 0) {
    return INDEX_NOT_FOUND;
} else if (startIndex >= array.length) {
    startIndex = array.length - 1;
double min = valueToFind - tolerance;
double max = valueToFind + tolerance;
for (int i = startIndex; i >= 0; i--) {
    if (array[i] >= min && array[i] <= max) {
        return i;
return INDEX_NOT_FOUND;
intlastIndexOf(float[] array, float 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(float[] array, float 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(int[] array, int 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(int[] array, int 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(long[] array, long 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(long[] array, long 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(short[] array, short 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(short[] array, short 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;