Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import java.util.Collection;

import java.util.Iterator;

import java.util.List;

public class Main {
    public static <T> T getAt(Collection<T> col, int index) {
        if (col instanceof List)
            return ((List<T>) col).get(index);
        int i;
        Iterator<T> it;
        for (i = 0, it = col.iterator(); i < index && it.hasNext(); it.next())
            ;
        return it.hasNext() ? it.next() : null;
    }
}