Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.ArrayList;
import java.util.Collection;

import java.util.List;

public class Main {

    public static int searchIndex(Collection<? extends Object> collection, Object value) {
        List<? extends Object> valueList = new ArrayList<Object>(collection);

        int i = 0;
        for (Object o : valueList) {
            if ((o == value) || ((o != null) && (o.equals(value)))) {
                return i;
            }
            i++;
        }
        return -1;
    }
}