1 package samples.reflect.hello1; 2 3 import java.lang.reflect.Method ; 4 5 public class Test { 6 public static void main(String args[]) throws Exception { 7 Class cl = Test.class; 8 Method m = cl.getMethod("helloWorld", new Class [] {}); 9 HelloWorld hw = (HelloWorld) cl.newInstance(); 10 m.invoke(hw, new Object [] {}); 11 } 12 13 public static void println(Object o) { 14 System.out.println(o); 15 } 16 } 17 | Popular Tags |