get Parameter Types - Java Reflection

Java examples for Reflection:Method Parameter

Description

get Parameter Types

Demo Code

/**/*w w w  . ja v a2  s . c  om*/
 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
 */
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class Main{

    public static Class[] getParameterTypes(String... parameterTypeNames) {
        Class[] parameterTypes = new Class[parameterTypeNames.length];
        for (int i = 0; i < parameterTypeNames.length; i++) {
            parameterTypes[i] = getClass(parameterTypeNames[i]);
        }
        return parameterTypes;
    }
    public static Class getClass(String name) {
        try {
            return ClassLoaderUtil.class.getClassLoader().loadClass(name);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
}

Related Tutorials