Here you can find the source of getMethod(Class> clazz, String name, Class>... args)
public static Method getMethod(Class<?> clazz, String name, Class<?>... args)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Method; public class Main { public static Method getMethod(Class<?> clazz, String name, Class<?>... args) { for (Method m : clazz.getMethods()) if (m.getName().equals(name) && (args.length == 0 || ClassListEqual(args, m.getParameterTypes()))) { m.setAccessible(true);/* w ww. j a v a 2s . c o m*/ return m; } return null; } public static boolean ClassListEqual(Class<?>[] l1, Class<?>[] l2) { boolean equal = true; if (l1.length != l2.length) return false; for (int i = 0; i < l1.length; i++) if (l1[i] != l2[i]) { equal = false; break; } return equal; } }