集册 Java实例教程 检查类是否为集合的方法。

检查类是否为集合的方法。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

358
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
检查类是否为集合的方法。


//package com.book2s;


import java.util.*;
/**
时 代 J a v a - N o w J a v a . c o m 提供 
**/


public class Main {

    public static void main(String[] argv) {

        Class c = String.class;

        System.out.println(isClassCollection(c));

    }


    /**

     * Method to check if a Class is a Collection or not.

     * @param c the Class to inspect.

     * @return if true the class extend or implememnt Collection.

     */

    public static boolean isClassCollection(Class<?> c) {

        return 
展开阅读全文