Here you can find the source of toClasses(Object[] objs)
public static Class[] toClasses(Object[] objs) throws ClassNotFoundException
//package com.java2s; /* /*ww w . j av a 2 s . c om*/ * 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 { public static Class[] toClasses(Object[] objs) throws ClassNotFoundException { Class[] classes; if (objs == null) { classes = new Class[] {}; } else if (objs instanceof Class[]) { classes = (Class[]) objs; } else if (objs instanceof String[]) { classes = forNames((String[]) objs); } else { classes = forObjects(objs); } return classes; } /** * 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; } /** * Returns the Class object array associated with the class or interface * with the given object array. * * @param objs the objects of the desired classes. * @return the Class object array for the classes with the specified * objects. */ public static Class[] forObjects(Object[] objs) { int size = (objs == null ? 0 : objs.length); Class[] classes = new Class[size]; for (int i = 0; i < classes.length; i++) { classes[i] = (objs[i] == null ? null : objs[i].getClass()); } return classes; } }