Return the signature of method as an array of strings. - Java Reflection

Java examples for Reflection:Method Return

Description

Return the signature of method as an array of strings.

Demo Code


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

public class Main {
    /**/* ww w.  j  a  v a  2  s .c om*/
     * Return the signature of method as an array of strings.
     *
     * @param method the method.
     * @return the signature.
     */
    public static String[] getSignature(final Method method) {
        final Class[] types = method.getParameterTypes();
        final String[] signature = new String[types.length];
        for (int i = 0; i < types.length; i++) {
            signature[i] = types[i].getName();
        }
        return signature;
    }
}

Related Tutorials