Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.Map; public class Main { static <K, V> int getCollectionSize(final Map<K, ? extends Collection<V>> map, final K key) { final Collection<V> values = map.get(key); if (values == null) { return 0; } else { return values.size(); } } 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++; } } } return null; } }