Java Collection Element Get get(Collection v, int i)

Here you can find the source of get(Collection v, int i)

Description

get

License

Apache License

Declaration

public static <T> T get(Collection<T> v, int i) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2014 Expedia Inc.//from   w ww.j  a  va 2 s.  c o m
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/

import java.util.Collection;
import java.util.Iterator;
import java.util.List;

public class Main {
    public static <T> T get(List<T> v, int i) {
        return v.get(i);
    }

    public static <T> T get(Collection<T> v, int i) {
        Iterator<T> itr = v.iterator();
        for (int k = 0; k < i; k++)
            itr.next();
        return itr.next();
    }

    public static <T> T get(T[] v, int i) {
        return v[i];
    }

    public static byte get(byte[] v, int i) {
        return v[i];
    }

    public static short get(short[] v, int i) {
        return v[i];
    }

    public static int get(int[] v, int i) {
        return v[i];
    }

    public static long get(long[] v, int i) {
        return v[i];
    }

    public static float get(float[] v, int i) {
        return v[i];
    }

    public static double get(double[] v, int i) {
        return v[i];
    }

    public static boolean get(boolean[] v, int i) {
        return v[i];
    }
}

Related

  1. get(Collection coll, int index)
  2. get(Collection p_collection, int p_index)
  3. get(Collection arr, int idx)
  4. get(Collection collection, int index)
  5. get(Collection p_oCol, T p_oObj)
  6. get(final Collection list, final int pos)
  7. get(final Collection collection, final int index)
  8. getAddedItems(Collection oldValues, Collection newValues)
  9. getAdditions(Collection source, Collection target)