方法反射实例

方法反射实例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public class ReflectCase {

public static void main(String[] args) throws Exception {
Proxy target = new Proxy();
Method method = Proxy.class.getDeclaredMethod("run");
method.invoke(target);
}

static class Proxy {
public void run() {
System.out.println("run");
}
}
}