Java Reflection - Java Class.getMethods()


Class.getMethods() has the following syntax.

public Method [] getMethods()   throws SecurityException


In the following code shows how to use Class.getMethods() method.

//from  w  w w . j a v  a  2s .c  o  m
import java.lang.reflect.Method;

public class Main {

  public static void main(String[] args) throws Exception {

    Class cls = Class.forName("java.awt.Label");
    System.out.println("Methods =");

    Method m[] = cls.getMethods();
    for (int i = 0; i < m.length; i++) {

The code above generates the following result.