检查列表(iterable)是否包含实例类c的内容
//package com.nowjava; /** from 时代Java公众号 - nowjava.com**/ public class Main { /** * Checks if the list (iterable) contains something of an instance class c * @param iterable a list of things * @param c class to check against * @param <T> Type of the list * @return if the list contains something of instance class c */ public static <T> boolean containsInstance(Iterable<T> iterable, Class c) { for (T t : iterable) { if (c.isInstance(t)) { return true; } } return false; }/* 来 自 N o w J a v a . c o m*/ }