import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class Test_Anonymous {
public static void main(String[] args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
Object o = new IRun(){
public void run() {
System.out.println("in anonymouse.run()");
}
};
System.out.println("class = " + o.getClass().getName());
Method[] methods= o.getClass().getMethods();
for (int i=0;i<methods.length;i++) {
System.out.println("method " + methods[i].getName());
}
//call the method
o.getClass().getMethod("run").invoke(o);
}//main
}//class
interface IRun {
void run();
}