Here you can find the source of indexOfIdentical(Object[] array, Object value)
public static int indexOfIdentical(Object[] array, Object value)
//package com.java2s; /*/*from www. j a va 2 s . com*/ * Copyright (c) 2017, APT Group, School of Computer Science, * The University of Manchester. All rights reserved. * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code 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 * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ import java.util.*; public class Main { /** * Returns the index in {@code list} of the first occurrence identical to {@code value}, or -1 if * {@code list} does not contain {@code value}. More formally, returns the lowest index * {@code i} such that {@code (list.get(i) == value)}, or -1 if there is no such index. */ public static int indexOfIdentical(List list, Object value) { int i = 0; for (Object element : list) { if (element == value) { return i; } ++i; } return -1; } /** * Returns the index in {@code array} of the first occurrence identical to {@code value}, or -1 if * {@code array} does not contain {@code value}. More formally, returns the lowest index * {@code i} such that {@code (array[i] == value)}, or -1 if there is no such index. */ public static int indexOfIdentical(Object[] array, Object value) { for (int i = 0; i < array.length; i++) { if (array[i] == value) { return i; } } return -1; } }