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.Method; public class Main { public static void main(String args[]) throws Exception { Class c = Class.forName("java.lang.String"); Method[] methods = c.getDeclaredMethods(); System.out.println("No. of methods in: " + methods.length); for (Method m : methods) System.out.println(m);//from w ww. jav a2 s . co m } }