Here you can find the source of invokeMethod(Object o, String fieldName)
public static Object invokeMethod(Object o, String fieldName)
//package com.java2s; //License from project: Apache License import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class Main { public static Object invokeMethod(Object o, String fieldName) { try {//from w w w. java 2 s. c o m final Method m = o.getClass().getMethod(fieldName); return m.invoke(o); } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { throw new RuntimeException("Reflection error!", e); } } }