Here you can find the source of forNames(String[] classNames)
Parameter | Description |
---|---|
classNames | the fully qualified names of the desired classes. |
Parameter | Description |
---|---|
ClassNotFoundException | an exception |
public static Class[] forNames(String[] classNames) throws ClassNotFoundException
//package com.java2s; /* // w w w. ja v a 2 s . c o m * Copyright(c) 2005 Center for E-Commerce Infrastructure Development, The * University of Hong Kong (HKU). All Rights Reserved. * * This software is licensed under the GNU GENERAL PUBLIC LICENSE Version 2.0 [1] * * [1] http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ public class Main { /** * Returns the Class object array associated with the class or interface * with the given string name array. * * @param classNames the fully qualified names of the desired classes. * @return the Class object array for the classes with the specified names. * @throws ClassNotFoundException */ public static Class[] forNames(String[] classNames) throws ClassNotFoundException { int size = (classNames == null ? 0 : classNames.length); Class[] classes = new Class[size]; for (int i = 0; i < classes.length; i++) { classes[i] = Class.forName(classNames[i]); } return classes; } }