Here you can find the source of getMethodValue(Object target, String methodName)
Parameter | Description |
---|---|
target | Object |
methodName | method name |
Parameter | Description |
---|---|
Exception | ex |
public static Object getMethodValue(Object target, String methodName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
//package com.java2s; import java.lang.reflect.*; public class Main { /**//from www . ja v a 2 s. c om * get method value by name. * * @param target Object * @param methodName method name * @return object * @throws Exception ex */ public static Object getMethodValue(Object target, String methodName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { Method method = target.getClass().getDeclaredMethod(methodName); return method.invoke(target); } }