Here you can find the source of getMethodByName(Class> clazz, String methodName)
public static Method getMethodByName(Class<?> clazz, String methodName)
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; public class Main { public static Method getMethodByName(Class<?> clazz, String methodName) { Method[] methods = clazz.getDeclaredMethods(); if (methods == null || methods.length == 0) { return null; }// ww w .j a v a2s.com if (methodName == null || methodName.length() == 0) { return null; } List<Method> methodList = new ArrayList<Method>(); for (Method method : methods) { if (method.getName().equals(methodName)) { methodList.add(method); } } if (methodList.size() == 0) { return null; } if (methodList.size() > 1) { return null; } return methodList.get(0); } }