Java Collection Element Get get(final Collection collection, final int index)

Here you can find the source of get(final Collection collection, final int index)

Description

get

License

Apache License

Declaration

static <T> T get(final Collection<T> collection, final int index) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Collection;

public class Main {
    static <T> T get(final Collection<T> collection, final int index) {
        if (collection != null) {
            int i = 0;
            for (final T object : collection) {
                if (i == index) {
                    return object;
                } else {
                    i++;// ww w . j  av a2s.c  om
                }
            }
        }
        return null;
    }
}

Related

  1. get(Collection arr, int idx)
  2. get(Collection collection, int index)
  3. get(Collection p_oCol, T p_oObj)
  4. get(Collection v, int i)
  5. get(final Collection list, final int pos)
  6. getAddedItems(Collection oldValues, Collection newValues)
  7. getAdditions(Collection source, Collection target)
  8. getAll(Map map, Collection indices)
  9. getAllDoubleValues( Map>> doubleCollectionWithValuesToFetch)