Here you can find the source of getMethodParametersType(Class> clazz, String methodName)
Parameter | Description |
---|---|
clazz | whose method required |
methodName | whose parameter required |
Parameter | Description |
---|---|
NoSuchMethodException | an exception |
public static Class<?>[] getMethodParametersType(Class<?> clazz, String methodName) throws NoSuchMethodException
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; public class Main { /**/*from w ww . ja v a 2 s .c o m*/ * Get the method parameter type array * @param clazz whose method required * @param methodName whose parameter required * @return Array of parameter type * @throws NoSuchMethodException */ public static Class<?>[] getMethodParametersType(Class<?> clazz, String methodName) throws NoSuchMethodException { for (Method method : clazz.getMethods()) { if (method.getName().equals(methodName)) { return method.getParameterTypes(); } } throw new NoSuchMethodException( "No such method is paresent in " + clazz.getName() + " of name " + methodName); } }