get Argument Names from Method - Java Reflection

Java examples for Reflection:Method Name

Description

get Argument Names from Method

Demo Code


//package com.java2s;
import java.lang.reflect.Method;

public class Main {

    public static String[] getArgumentNames(Method method) {
        String[] rets = new String[] {};
        Class<?>[] parameters = method.getParameterTypes();
        for (int i = 0; i < parameters.length; i++) {
            rets[i] = parameters[i].getName();
        }/*www.  j a v  a 2s .c  om*/

        return rets;
    }
}

Related Tutorials