The following methods are available to retrieve methods of a class:
public Method getDeclaredMethod(String name, Class<?>... parameterTypes) public Method[] getDeclaredMethods() public Method getMethod(String name, Class<?>... parameterTypes) public Method[] getMethods()
import java.lang.reflect.Field; import java.lang.reflect.Method; public class Main { public static void main(String args[]) throws Exception { print(Class.forName("javax.swing.JLabel")); }/*w ww .ja v a 2 s . c om*/ static int v = 0; static void print(Class c) { if (c != null) { print(c.getSuperclass()); Method[] methods = c.getDeclaredMethods(); indent(v); System.out.println("Class: " + c); for (Method f : methods) { indent(v); System.out.println(f); } v++; } } static void indent(int n) { for (int i = 0; i < n; i++) System.out.print(" "); } }