Here you can find the source of get(Collection
public static <T> T get(Collection<T> v, int i)
//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]; } }