Here you can find the source of getByIndex(Collection
public static Object getByIndex(Collection<Object> availableTransitions, int index)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010-2014, Miklos Foldenyi, Andras Szabolcs Nagy, Abel Hegedus, Akos Horvath, Zoltan Ujhelyi and Daniel Varro * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * Contributors://from w w w .j a v a2 s . c om * Miklos Foldenyi - initial API and implementation * Andras Szabolcs Nagy - initial API and implementation *******************************************************************************/ import java.util.Collection; import java.util.Iterator; public class Main { public static Object getByIndex(Collection<Object> availableTransitions, int index) { int i = 0; Iterator<Object> iterator = availableTransitions.iterator(); while (iterator.hasNext()) { Object transition = iterator.next(); if (i == index) { return transition; } else { ++i; } } throw new IndexOutOfBoundsException("size: " + i + ", index: " + index); } }