Here you can find the source of invokeGet(Object o, String fieldName)
public static Object invokeGet(Object o, String fieldName)
//package com.java2s; import java.lang.reflect.Method; public class Main { public static Object invokeGet(Object o, String fieldName) { Method method = getGetMethod(o.getClass(), fieldName); try {/*from w w w . j a va 2 s . com*/ return method.invoke(o, new Object[0]); } catch (Exception e) { e.printStackTrace(); } return null; } public static Method getGetMethod(Class objectClass, String fieldName) { StringBuffer sb = new StringBuffer(); sb.append("get"); sb.append(fieldName.substring(0, 1).toUpperCase()); sb.append(fieldName.substring(1)); try { return objectClass.getMethod(sb.toString()); } catch (Exception e) { } return null; } }