Java List IndexOf indexOf(Object o, Collection list)

Here you can find the source of indexOf(Object o, Collection list)

Description

get an index of object in the collection.

License

Open Source License

Parameter

Parameter Description
o the o
list the list

Return

the int

Declaration

public static int indexOf(Object o, Collection list) 

Method Source Code

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

import java.util.Collection;

import java.util.List;

public class Main {
    /**//www  .  j  a  v  a  2  s.co  m
     * Index of.
     *
     * @param list the list
     * @param w the w
     * @param n the n
     * @return the int
     */
    public static int indexOf(List<String> list, String w, int n) {
        for (int i = n; i < list.size(); i++) {
            if (list.get(i).equals(w))
                return i;
        }
        return -1;
    }

    /**
     * get an index of object in the collection.
     *
     * @param o the o
     * @param list the list
     * @return the int
     */
    public static int indexOf(Object o, Collection list) {
        int n = 1;
        for (Object oo : list) {
            if (oo.equals(0)) {
                return n;
            }
            n++;
        }
        return -1;
    }
}

Related

  1. indexOf(List list, Object element, int begin, int end)
  2. indexOf(List data, List token)
  3. indexOf(List source, List target)
  4. indexOf(List lines, String... conditions)
  5. indexOf(List list, T string, int beginIndex)
  6. indexOfFactory(List factories, Class classInstance)
  7. indexOfId(List aList, Object anObj)
  8. indexOfIdentical(List list, Object value)
  9. indexOfIdentity(List l, T t)