Java 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(byte[] array, byte[] target, int start)
origin: https://code.google.com/p/guava-libraries/source/browse/guava/src/com/google/common/primitives/Bytes.java Returns the start position of the first occurrence of the specified target within array , or -1 if there is no such occurrence.
checkNotNull(array, "array");
checkNotNull(target, "target");
if (target.length == 0) {
    return 0;
outer: for (int i = start; i < array.length - target.length + 1; i++) {
    for (int j = 0; j < target.length; j++) {
        if (array[i + j] != target[j]) {
...
intindexOf(byte[] target, byte[] key)
index Of
return indexOf(target, key, 0);
intindexOf(char toBeFound, char[] array)
index Of
for (int i = 0; i < array.length; i++) {
    if (toBeFound == array[i])
        return i;
return -1;
intindexOf(final String[] p_elements, final String p_key)
index Of
if (p_elements == null) {
    return -1;
return Arrays.asList(p_elements).indexOf(p_key);
intindexOf(final T[] array, final T value)
index Of
final int alen = array.length;
for (int i = 0; i < alen; i++) {
    if (value.equals(array[i])) {
        return i;
return INDEX_NOT_FOUND;
intindexOf(int[] arr, int e)
index Of
for (int i = 0; i < arr.length; i++) {
    if (arr[i] == e) {
        return i;
return -1;
intindexOf(int[] arr, int val)
index Of
if (arr == null)
    return -1;
for (int i = 0; i < arr.length; i++)
    if (arr[i] == val)
        return i;
return -1;
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)

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[] elements, Object value)
Returns the index of the first occurrence of the specified element in this array, or -1 if this list does not contain the element.
int index = 0;
for (Object element : elements) {
    if (equals(element, value)) {
        return index;
    ++index;
return -1;
...