Here you can find the source of getMethod(Object obj, String methodName)
static Method getMethod(Object obj, String methodName)
//package com.java2s; //License from project: LGPL import java.lang.reflect.Method; import java.util.Locale; public class Main { static Method getMethod(Object obj, String methodName) { Method[] ms = obj.getClass().getMethods(); for (Method m : ms) { if (m.getName().equals(methodName)) { return m; }/*ww w .j a v a 2 s. c o m*/ } if (methodName.contains("_")) { String[] nameSet = methodName.split("_"); StringBuilder name = new StringBuilder(nameSet[0]); for (int i = 1; i < nameSet.length; i++) { String item = nameSet[i]; if (item.length() > 0) { name.append(item.substring(0, 1).toUpperCase(Locale.ENGLISH)); name.append(item.substring(1)); } } return getMethod(obj, name.toString()); } return null; } }