Android Utililty Methods Array Index Of

List of utility methods to do Array Index Of

Description

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

Method

intindexOf(Object[] array, Object obj)
index Of
for (int i = 0; i < array.length; ++i) {
    if (obj == array[i]) {
        return i;
throw new NoSuchElementException("" + obj);
intindexOf(Object[] array, Object objectToFind)

Finds the index of the given object in the array.

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

return indexOf(array, objectToFind, 0);
intindexOf(Object[] array, Object objectToFind, int startIndex)

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

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

A negative startIndex is treated as zero.

if (array == null) {
    return INDEX_NOT_FOUND;
if (startIndex < 0) {
    startIndex = 0;
if (objectToFind == null) {
    for (int i = startIndex; i < array.length; i++) {
...
intindexOf(T e, T[] array)
index Of
for (int i = 0; i != array.length; ++i) {
    if (array[i].equals(e))
        return i;
return -1;
intindexOf(boolean[] array, boolean valueToFind)

Finds the index of the given value in the array.

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

return indexOf(array, valueToFind, 0);
intindexOf(boolean[] array, boolean valueToFind, int startIndex)

Finds the 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 is treated as zero.

if (ArrayUtils.isEmpty(array)) {
    return INDEX_NOT_FOUND;
if (startIndex < 0) {
    startIndex = 0;
for (int i = startIndex; i < array.length; i++) {
    if (valueToFind == array[i]) {
...
intindexOf(byte[] array, byte valueToFind)

Finds the index of the given value in the array.

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

return indexOf(array, valueToFind, 0);
intindexOf(byte[] array, byte valueToFind, int startIndex)

Finds the 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 is treated as zero.

if (array == null) {
    return INDEX_NOT_FOUND;
if (startIndex < 0) {
    startIndex = 0;
for (int i = startIndex; i < array.length; i++) {
    if (valueToFind == array[i]) {
...
intindexOf(char[] array, char valueToFind)

Finds the index of the given value in the array.

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

return indexOf(array, valueToFind, 0);
intindexOf(char[] array, char valueToFind, int startIndex)

Finds the 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 is treated as zero.

if (array == null) {
    return INDEX_NOT_FOUND;
if (startIndex < 0) {
    startIndex = 0;
for (int i = startIndex; i < array.length; i++) {
    if (valueToFind == array[i]) {
...