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

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

Description

Get method by name (declared)

License

Open Source License

Parameter

Parameter Description
c The class
name The name

Return

The method

Declaration

public static Method getMethod(Class<?> c, String name) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.lang.reflect.*;

public class Main {
    /**/*from   w w w  .  j a  v  a 2 s . c  om*/
     * Get method by name (declared)
     *
     * @param c    The class
     * @param name The name
     * @return The method
     */
    public static Method getMethod(Class<?> c, String name) {
        for (Method m : c.getMethods()) {
            if (m.getName().equals(name))
                return m;
        }
        return null;
    }
}

Related

  1. getMethod(Class targetClass, String targetMethodName)
  2. getMethod(Class theClass, String propertyName)
  3. getMethod(Class type, String name, Class[] paramTypes)
  4. getMethod(Class beanClass, String methodName, Class[] types)
  5. getMethod(Class c, String name)
  6. getMethod(Class c, String name, Class[] args)
  7. getMethod(Class clazz, String methodName)
  8. getMethod(Class clazz, String methodName, Class fieldType)
  9. getMethod(Class clazz, String methodName, Class... arguments)