Java Reflection Method Name getMethod(Class c, String name)

Here you can find the source of getMethod(Class c, String name)

Description

get Method

License

Apache License

Declaration

public static Method getMethod(Class c, String name) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.lang.reflect.Method;

public class Main {
    public static Method getMethod(Class c, String name) {
        for (Method method : c.getDeclaredMethods()) {
            if (method.getName().equals(name)) {
                return method;
            }//from ww  w  . j a v  a2  s .  c o m
        }
        throw new IllegalArgumentException("Unknown method '" + name + "' on " + c);
    }
}

Related

  1. getMethod(@Nonnull Class clazz, @Nonnull String methodName, @Nonnull Class... types)
  2. getMethod(Class c, String methodName)
  3. getMethod(Class cl, String methodName, Class[] paramTypes)
  4. getMethod(Class clazz, String methodName)
  5. getMethod(Class clazz, String methodName, Class argType)
  6. getMethod(Class clazz, String methodName, Class[] classes)