Java tutorial
//package com.java2s; import java.lang.reflect.Method; public class Main { public static Object getValueByMethodName(Object o, String methodName) { try { Method method = o.getClass().getMethod(methodName, new Class[] {}); Object value = method.invoke(o, new Object[] {}); return value; } catch (Exception e) { e.printStackTrace(); return null; } } }