Java tutorial
//package com.java2s; import java.lang.reflect.Method; public class Main { public static Object invokeObjectMethod(Object object, String methodName, Class[] argsClass, Object[] args) { Object returnValue = null; try { Class<?> c = object.getClass(); Method method; method = c.getMethod(methodName, argsClass); returnValue = method.invoke(object, args); } catch (Exception e) { e.printStackTrace(); } return returnValue; } }