Java Reflection Method Return getMethodReturnType(Class clazz, String methodName)

Here you can find the source of getMethodReturnType(Class clazz, String methodName)

Description

Returns return type of given method in given class.

License

Open Source License

Declaration

public static Class<?> getMethodReturnType(Class<?> clazz, String methodName) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.lang.reflect.Method;

public class Main {
    /**//from   www  . j  a  v a2 s . c om
     * Returns return type of given method in given class.
     */
    public static Class<?> getMethodReturnType(Class<?> clazz, String methodName) {
        try {
            Method method = clazz.getDeclaredMethod(methodName);
            return method.getReturnType();
        } catch (NoSuchMethodException e) {
            throw new AssertionError(e);
        } catch (SecurityException e) {
            throw new AssertionError(e);
        }
    }
}

Related

  1. getMethodGenericReturnType(Method method, Class rawType, int index)
  2. getMethodGenericReturnType(Method method, int index)
  3. getMethodGenericReturnType(Method method, int index)
  4. getMethodInvoker(final Class returnType, final String methodName)
  5. getMethodNoArgs(final Class objClass, final String methodName, final Class... returnTypePreference)
  6. getMethodReturnType(Class clazz, String name)
  7. getMethodReturnType(Class clazz, String name)