Here you can find the source of getMethod(Class> klass, String methodName, Object... params)
public static Method getMethod(Class<?> klass, String methodName, Object... params) throws SecurityException, NoSuchMethodException
//package com.java2s; /*//from w ww. j a v a 2s .c o m * This file is part of Cotopaxi. * * Cotopaxi is free software: you can redistribute it and/or modify * it under the terms of the Lesser GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or * any later version. * * Cotopaxi is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * Lesser GNU General Public License for more details. * * You should have received a copy of the Lesser GNU General Public License * along with Cotopaxi. If not, see <http://www.gnu.org/licenses/>. */ import java.lang.reflect.Method; public class Main { private static final Class<?>[] EMPTY_CLASS_PARAMS = new Class[0]; public static Method getMethod(Class<?> klass, String methodName, Object... params) throws SecurityException, NoSuchMethodException { Class<?>[] classes = (params.length != 0) ? new Class<?>[params.length] : EMPTY_CLASS_PARAMS; for (int i = 0; i < params.length; i++) { classes[i] = params[i].getClass(); } return klass.getMethod(methodName, classes); } /** * Gets an {@link Class} by name. */ public static Class<?> getClass(String className) throws ClassNotFoundException { return Class.forName(className); } }