Posted by Carl on 06/06/07 22:11
"Jon Slaughter" <Jon_Slaughter@Hotmail.com> writes:
> is it possible to iterate through the methods in a class?
>
> Thanks,
> Jon
If you want to see the public member methods you can do
something like this:
----8<----
package test;
import java.lang.reflect.Method;
public class Test {
public static void main(String[] args)
throws ClassNotFoundException {
Class c = Class.forName("java.lang.reflect.Method");
Method methods[] = c.getMethods();
for (Method m : methods) {
System.out.println(m);
}
}
}
---->8----
Docs here:
http://java.sun.com/javase/6/docs/api/java/lang/Class.html#getMethods()
Hope that helps,
Carl.
Navigation:
[Reply to this message]
|