Java Array Index Of arrayIndexOf(Object[] array, Object element)

Here you can find the source of arrayIndexOf(Object[] array, Object element)

Description

array Index Of

License

Open Source License

Declaration

public static int arrayIndexOf(Object[] array, Object element) 

Method Source Code

//package com.java2s;
/*/* w  w w. j  a v a2  s .co  m*/
SongScribe song notation program
Copyright (C) 2006 Csaba Kavai
    
This file is part of SongScribe.
    
SongScribe is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
    
SongScribe is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
Created on Aug 6, 2006
*/

public class Main {
    public static int arrayIndexOf(Object[] array, Object element) {
        for (int i = 0; i < array.length; i++) {
            if (element.equals(array[i])) {
                return i;
            }
        }

        return -1;
    }
}

Related

  1. arrayIndexClean(String indx)
  2. arrayIndexFor(final String raw)
  3. ArrayIndexOf(byte[] data, byte[] dest)
  4. arrayIndexOf(int needle, int[] haystack)
  5. arrayIndexOf(int value, int[] arr)
  6. arrayIndexOffset(int index, long baseOffset, long indexScale)
  7. indexOf(byte[] array, byte[] target, int fromIndex)
  8. indexOf(byte[] array, byte[] target, int start)
  9. indexOf(byte[] target, byte[] key)