获取iterable中类c的实例
//package com.nowjava; import java.util.ArrayList; /*来自 时代Java - nowjava.com*/ import java.util.List; public class Main { /** * Gets the instances of Class c in iterable * @param iterable iterable with instances * @param c class of generic type E * @param <E> Type of the list to return and the generic of c * @return List\<E> where object in list is an instanceof class c of generic type E */ public static <E> List<E> getInstances(Iterable iterable, Class<E> c) { ArrayList<E> result = new ArrayList<E>(); for (Object obj : iterable) {