Java Collection Element Get get(Collection arr, int idx)

Here you can find the source of get(Collection arr, int idx)

Description

get

License

Open Source License

Parameter

Parameter Description
arr a parameter
oid a parameter

Declaration

public static Object get(Collection<?> arr, int idx) 

Method Source Code

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

import java.util.Collection;

import java.util.Iterator;

public class Main {
    /**//  www . j a  v a 2  s . c o  m
     * @param arr
     * @param oid
     * @return
     */
    public static Object get(Collection<?> arr, int idx) {
        if (idx < 0)
            return null;
        for (Iterator<?> i = arr.iterator(); i.hasNext(); idx--) {
            Object b = i.next();
            if (idx <= 0)
                return b;
        }
        return null;
    }
}

Related

  1. get(Collection coll, int index)
  2. get(Collection p_collection, int p_index)
  3. get(Collection collection, int index)
  4. get(Collection p_oCol, T p_oObj)
  5. get(Collection v, int i)
  6. get(final Collection list, final int pos)