Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static int indexOf(Object[] array, Object item) {
        if (item == null || array == null) {
            return -1;
        }

        for (int i = 0; i < array.length; i++) {
            Object o = array[i];
            if (o == item) {
                return i;
            }

            if (o != null) {
                if (o.equals(item)) {
                    return i;
                }
            }
        }
        return -1;
    }
}