Java Array Index Of indexOf(int[] arr, int e)

Here you can find the source of indexOf(int[] arr, int e)

Description

index Of

License

Open Source License

Declaration

public static int indexOf(int[] arr, int e) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.List;

public class Main {

    public static int indexOf(int[] arr, int e) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == e) {
                return i;
            }// w  w  w  .  ja v a  2s.co m
        }
        return -1;
    }

    public static int indexOf(String[] arr, String e) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i].equals(e)) {
                return i;
            }
        }
        return -1;
    }

    public static int indexOf(List<Integer> list, Integer value) {
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i) == value) {
                return i;
            }
        }
        return -1;
    }
}

Related

  1. indexOf(byte[] array, byte[] target, int start)
  2. indexOf(byte[] target, byte[] key)
  3. indexOf(char toBeFound, char[] array)
  4. indexOf(final String[] p_elements, final String p_key)
  5. indexOf(final T[] array, final T value)
  6. indexOf(int[] arr, int val)
  7. indexOf(Object[] array, Object objectToFind)
  8. indexOf(Object[] array, Object objectToFind)
  9. indexOf(Object[] elements, Object value)