// File Reflect1.java import java.lang.reflect.*; // Method class Reflect1 { public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { Class ty = Reflect1.class; // Get Reflect1 class Method m = ty.getMethod("Foo", new Class[] {}); // Get Foo() method m.invoke(null, new Object[] { }); // Call it } public static void Foo() { System.out.println("Foo"); } }